Search in sources :

Example 1 with IDocDocument

use of com.sap.conn.idoc.IDocDocument in project iaf by ibissource.

the class SapListener method handleRequest.

public void handleRequest(JCoServerContext serverCtx, IDocDocumentList documentList) {
    log.debug(getLogPrefix() + "Incoming IDoc list request containing " + documentList.getNumDocuments() + " documents...");
    IDocXMLProcessor xmlProcessor = JCoIDoc.getIDocFactory().getIDocXMLProcessor();
    IDocDocumentIterator iterator = documentList.iterator();
    IDocDocument doc = null;
    while (iterator.hasNext()) {
        doc = iterator.next();
        log.debug(getLogPrefix() + "Processing document no. [" + doc.getIDocNumber() + "] of type [" + doc.getIDocType() + "]");
        try {
            handler.processRequest(this, xmlProcessor.render(doc));
        } catch (Throwable t) {
            log.warn(getLogPrefix() + "Exception caught and handed to SAP", t);
            throw new JCoRuntimeException(JCoException.JCO_ERROR_APPLICATION_EXCEPTION, "IbisException", t.getMessage());
        }
    }
}
Also used : IDocDocumentIterator(com.sap.conn.idoc.IDocDocumentIterator) IDocDocument(com.sap.conn.idoc.IDocDocument) JCoRuntimeException(com.sap.conn.jco.JCoRuntimeException) IDocXMLProcessor(com.sap.conn.idoc.IDocXMLProcessor)

Example 2 with IDocDocument

use of com.sap.conn.idoc.IDocDocument in project iaf by ibissource.

the class IdocSender method sendMessage.

public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
    String tid = null;
    try {
        ParameterValueList pvl = null;
        if (prc != null) {
            pvl = prc.getValues(paramList);
        }
        SapSystem sapSystem = getSystem(pvl);
        IDocDocument idoc = parseIdoc(sapSystem, message);
        try {
            log.debug(getLogPrefix() + "checking syntax");
            idoc.checkSyntax();
        } catch (IDocException e) {
            throw new SenderException("Syntax error in idoc", e);
        }
        if (log.isDebugEnabled()) {
            log.debug(getLogPrefix() + "parsed idoc [" + JCoIDoc.getIDocFactory().getIDocXMLProcessor().render(idoc) + "]");
        }
        JCoDestination destination = getDestination(prc.getSession(), sapSystem);
        tid = getTid(destination, sapSystem);
        if (tid == null) {
            throw new SenderException("could not obtain TID to send Idoc");
        }
        JCoIDoc.send(idoc, IDocFactory.IDOC_VERSION_DEFAULT, destination, tid);
        return tid;
    } catch (Exception e) {
        throw new SenderException(e);
    }
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) JCoDestination(com.sap.conn.jco.JCoDestination) IDocDocument(com.sap.conn.idoc.IDocDocument) SenderException(nl.nn.adapterframework.core.SenderException) IDocException(com.sap.conn.idoc.IDocException) IDocException(com.sap.conn.idoc.IDocException) SenderException(nl.nn.adapterframework.core.SenderException) TimeOutException(nl.nn.adapterframework.core.TimeOutException)

Aggregations

IDocDocument (com.sap.conn.idoc.IDocDocument)2 IDocDocumentIterator (com.sap.conn.idoc.IDocDocumentIterator)1 IDocException (com.sap.conn.idoc.IDocException)1 IDocXMLProcessor (com.sap.conn.idoc.IDocXMLProcessor)1 JCoDestination (com.sap.conn.jco.JCoDestination)1 JCoRuntimeException (com.sap.conn.jco.JCoRuntimeException)1 SenderException (nl.nn.adapterframework.core.SenderException)1 TimeOutException (nl.nn.adapterframework.core.TimeOutException)1 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)1