Search in sources :

Example 1 with Soap11Header

use of com.helger.phase4.soap11.Soap11Header in project phase4 by phax.

the class AbstractAS4Message method getAsSoapDocument.

@Nonnull
public final Document getAsSoapDocument(@Nullable final Node aPayload) {
    // Convert to DOM Node
    final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(m_aMessaging);
    if (aEbms3Document == null)
        throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
    final Node aRealPayload = aPayload instanceof Document ? ((Document) aPayload).getDocumentElement() : aPayload;
    switch(m_eSoapVersion) {
        case SOAP_11:
            {
                // Creating SOAP 11 Envelope
                final Soap11Envelope aSoapEnv = new Soap11Envelope();
                aSoapEnv.setHeader(new Soap11Header());
                aSoapEnv.setBody(new Soap11Body());
                aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
                if (aRealPayload != null)
                    aSoapEnv.getBody().addAny(aRealPayload);
                return Ebms3WriterBuilder.soap11().getAsDocument(aSoapEnv);
            }
        case SOAP_12:
            {
                // Creating SOAP 12 Envelope
                final Soap12Envelope aSoapEnv = new Soap12Envelope();
                aSoapEnv.setHeader(new Soap12Header());
                aSoapEnv.setBody(new Soap12Body());
                aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
                if (aRealPayload != null)
                    aSoapEnv.getBody().addAny(aRealPayload);
                return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
            }
        default:
            throw new IllegalStateException("Unsupported SOAP version " + m_eSoapVersion);
    }
}
Also used : Soap11Envelope(com.helger.phase4.soap11.Soap11Envelope) Soap12Envelope(com.helger.phase4.soap12.Soap12Envelope) Soap11Header(com.helger.phase4.soap11.Soap11Header) Node(org.w3c.dom.Node) Soap12Header(com.helger.phase4.soap12.Soap12Header) Soap11Body(com.helger.phase4.soap11.Soap11Body) Soap12Body(com.helger.phase4.soap12.Soap12Body) Document(org.w3c.dom.Document) Nonnull(javax.annotation.Nonnull)

Aggregations

Soap11Body (com.helger.phase4.soap11.Soap11Body)1 Soap11Envelope (com.helger.phase4.soap11.Soap11Envelope)1 Soap11Header (com.helger.phase4.soap11.Soap11Header)1 Soap12Body (com.helger.phase4.soap12.Soap12Body)1 Soap12Envelope (com.helger.phase4.soap12.Soap12Envelope)1 Soap12Header (com.helger.phase4.soap12.Soap12Header)1 Nonnull (javax.annotation.Nonnull)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1