Search in sources :

Example 1 with Soap12Envelope

use of com.helger.phase4.soap12.Soap12Envelope 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)

Example 2 with Soap12Envelope

use of com.helger.phase4.soap12.Soap12Envelope in project phase4 by phax.

the class Ebms3MessagingTest method _getMessagingAsSoapDocument.

@Nullable
private Document _getMessagingAsSoapDocument(@Nonnull final Ebms3Messaging aEbms3Messaging) {
    final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(aEbms3Messaging);
    if (aEbms3Document == null)
        throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
    // Creating SOAP 12 Envelope
    final Soap12Envelope aSoapEnv = new Soap12Envelope();
    aSoapEnv.setHeader(new Soap12Header());
    aSoapEnv.setBody(new Soap12Body());
    aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
    return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
}
Also used : Soap12Envelope(com.helger.phase4.soap12.Soap12Envelope) Soap12Header(com.helger.phase4.soap12.Soap12Header) Soap12Body(com.helger.phase4.soap12.Soap12Body) Document(org.w3c.dom.Document) Nullable(javax.annotation.Nullable)

Aggregations

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