Search in sources :

Example 1 with Soap12Header

use of com.helger.phase4.soap12.Soap12Header in project hop by apache.

the class WsdlUtils method getSOAPHeaders.

/**
 * Build a HashSet of SOAP header names for the specified operation and binding.
 *
 * @param binding WSDL Binding instance.
 * @param operationName Name of the operation.
 * @return HashSet of soap header names, empty set if no headers present.
 */
protected static HashSet<String> getSOAPHeaders(Binding binding, String operationName) {
    List<ExtensibilityElement> headers = new ArrayList<>();
    BindingOperation bindingOperation = binding.getBindingOperation(operationName, null, null);
    if (bindingOperation == null) {
        throw new IllegalArgumentException("Can not find operation: " + operationName);
    }
    BindingInput bindingInput = bindingOperation.getBindingInput();
    if (bindingInput != null) {
        headers.addAll(WsdlUtils.findExtensibilityElements((ElementExtensible) bindingInput, SOAP_HEADER_ELEMENT_NAME));
    }
    BindingOutput bindingOutput = bindingOperation.getBindingOutput();
    if (bindingOutput != null) {
        headers.addAll(WsdlUtils.findExtensibilityElements((ElementExtensible) bindingOutput, SOAP_HEADER_ELEMENT_NAME));
    }
    HashSet<String> headerSet = new HashSet<>(headers.size());
    for (ExtensibilityElement element : headers) {
        if (element instanceof SOAP12Header) {
            headerSet.add(((SOAP12Header) element).getPart());
        } else {
            headerSet.add(((SOAPHeader) element).getPart());
        }
    }
    return headerSet;
}
Also used : ElementExtensible(javax.wsdl.extensions.ElementExtensible) SOAP12Header(javax.wsdl.extensions.soap12.SOAP12Header) ArrayList(java.util.ArrayList) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) HashSet(java.util.HashSet)

Example 2 with Soap12Header

use of com.helger.phase4.soap12.Soap12Header 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 3 with Soap12Header

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

Example 4 with Soap12Header

use of com.helger.phase4.soap12.Soap12Header in project axis-axis2-java-core by apache.

the class DescriptionUtils method getNamespaceFromSOAPElement.

/**
 * This method will loop through a list of extensibility elements looking for one
 * of four objects: SOAPBody, SOAP12Body, SOAPHeader, SOAP12Header. If any of these
 * objects are found the namespace URI from this object will be returned.
 */
public static String getNamespaceFromSOAPElement(List extElements) {
    Iterator extIter = extElements.iterator();
    while (extIter.hasNext()) {
        Object extObj = extIter.next();
        if (extObj instanceof SOAPBody) {
            if (log.isDebugEnabled()) {
                log.debug("Returning SOAPBody namespace: " + ((SOAPBody) extObj).getNamespaceURI());
            }
            return ((SOAPBody) extObj).getNamespaceURI();
        } else if (extObj instanceof SOAP12Body) {
            if (log.isDebugEnabled()) {
                log.debug("Returning SOAP12Body namespace: " + ((SOAP12Body) extObj).getNamespaceURI());
            }
            return ((SOAP12Body) extObj).getNamespaceURI();
        } else if (extObj instanceof SOAPHeader) {
            if (log.isDebugEnabled()) {
                log.debug("Returning SOAPHeader namespace: " + ((SOAPHeader) extObj).getNamespaceURI());
            }
            return ((SOAPHeader) extObj).getNamespaceURI();
        } else if (extObj instanceof SOAP12Header) {
            if (log.isDebugEnabled()) {
                log.debug("Returning SOAP12Header namespace: " + ((SOAP12Header) extObj).getNamespaceURI());
            }
            return ((SOAP12Header) extObj).getNamespaceURI();
        } else if (extObj instanceof MIMEMultipartRelated) {
            if (log.isDebugEnabled()) {
                log.debug("Found a MIMEMultipartRelated element.  Unwrapping to get SOAP binding.");
            }
            MIMEMultipartRelated mime = (MIMEMultipartRelated) extObj;
            List mimeParts = mime.getMIMEParts();
            Iterator itr = mimeParts.iterator();
            while (itr.hasNext()) {
                MIMEPart mimePart = (MIMEPart) itr.next();
                List elements = mimePart.getExtensibilityElements();
                String ns = getNamespaceFromSOAPElement(elements);
                return ns;
            }
        }
    }
    return null;
}
Also used : SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) SOAP12Header(javax.wsdl.extensions.soap12.SOAP12Header) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SOAPHeader(javax.wsdl.extensions.soap.SOAPHeader) MIMEMultipartRelated(javax.wsdl.extensions.mime.MIMEMultipartRelated) MIMEPart(javax.wsdl.extensions.mime.MIMEPart)

Example 5 with Soap12Header

use of com.helger.phase4.soap12.Soap12Header in project pentaho-kettle by pentaho.

the class WsdlUtils method getSOAPHeaders.

/**
 * Build a HashSet of SOAP header names for the specified operation and binding.
 *
 * @param binding
 *          WSDL Binding instance.
 * @param operationName
 *          Name of the operation.
 * @return HashSet of soap header names, empty set if no headers present.
 */
protected static HashSet<String> getSOAPHeaders(Binding binding, String operationName) {
    List<ExtensibilityElement> headers = new ArrayList<ExtensibilityElement>();
    BindingOperation bindingOperation = binding.getBindingOperation(operationName, null, null);
    if (bindingOperation == null) {
        throw new IllegalArgumentException("Can not find operation: " + operationName);
    }
    BindingInput bindingInput = bindingOperation.getBindingInput();
    if (bindingInput != null) {
        headers.addAll(WsdlUtils.findExtensibilityElements(bindingInput, SOAP_HEADER_ELEMENT_NAME));
    }
    BindingOutput bindingOutput = bindingOperation.getBindingOutput();
    if (bindingOutput != null) {
        headers.addAll(WsdlUtils.findExtensibilityElements(bindingOutput, SOAP_HEADER_ELEMENT_NAME));
    }
    HashSet<String> headerSet = new HashSet<String>(headers.size());
    for (ExtensibilityElement element : headers) {
        if (element instanceof SOAP12Header) {
            headerSet.add(((SOAP12Header) element).getPart());
        } else {
            headerSet.add(((SOAPHeader) element).getPart());
        }
    }
    return headerSet;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) BindingOutput(javax.wsdl.BindingOutput) SOAP12Header(javax.wsdl.extensions.soap12.SOAP12Header) ArrayList(java.util.ArrayList) BindingInput(javax.wsdl.BindingInput) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)4 SOAP12Header (javax.wsdl.extensions.soap12.SOAP12Header)4 HashSet (java.util.HashSet)3 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)3 Soap12Body (com.helger.phase4.soap12.Soap12Body)2 Soap12Envelope (com.helger.phase4.soap12.Soap12Envelope)2 Soap12Header (com.helger.phase4.soap12.Soap12Header)2 Iterator (java.util.Iterator)2 List (java.util.List)2 MIMEPart (javax.wsdl.extensions.mime.MIMEPart)2 SOAPHeader (javax.wsdl.extensions.soap.SOAPHeader)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2 Soap11Body (com.helger.phase4.soap11.Soap11Body)1 Soap11Envelope (com.helger.phase4.soap11.Soap11Envelope)1 Soap11Header (com.helger.phase4.soap11.Soap11Header)1 HashMap (java.util.HashMap)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 BindingInput (javax.wsdl.BindingInput)1