Search in sources :

Example 11 with Soap12Body

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

the class DescriptionUtils method processBindingForMIME.

/**
 * This method will loop through the extensibility elements for a given BindingInput or
 * BindingOutput element and determine if it has any MIMEMultipartRelated content. If it
 * does it will build up the appropriate AttachmentDescription objects.
 */
private static void processBindingForMIME(List extensibilityElements, OperationDescriptionImpl opDesc, Operation operation, boolean isRequest) {
    Iterator extensibilityIter = extensibilityElements.iterator();
    while (extensibilityIter.hasNext()) {
        Object obj = extensibilityIter.next();
        if (obj instanceof MIMEMultipartRelated) {
            if (log.isDebugEnabled()) {
                log.debug("Found a mime:multipartRelated extensiblity element.");
            }
            // Found mime information now process it and determine if we need to
            // create an AttachmentDescription
            MIMEMultipartRelated mime = (MIMEMultipartRelated) obj;
            Iterator partIter = mime.getMIMEParts().iterator();
            while (partIter.hasNext()) {
                if (log.isDebugEnabled()) {
                    log.debug("Found a mime:part child element.");
                }
                MIMEPart mimePart = (MIMEPart) partIter.next();
                Iterator mExtIter = mimePart.getExtensibilityElements().iterator();
                // Process each mime part to determine if there is mime content
                while (mExtIter.hasNext()) {
                    Object obj2 = mExtIter.next();
                    // For mime content we need to potentially create an AttachmentDescription
                    if (obj2 instanceof MIMEContent) {
                        MIMEContent mimeContent = (MIMEContent) obj2;
                        String part = mimeContent.getPart();
                        String type = mimeContent.getType();
                        // if we have not already processed this part for the operation
                        if (opDesc.getPartAttachmentDescription(part) == null) {
                            if (log.isDebugEnabled()) {
                                log.debug("Adding new AttachmentDescription for part: " + part + " on operation: " + opDesc.getOperationName());
                            }
                            AttachmentDescription attachmentDesc = new AttachmentDescriptionImpl(AttachmentType.SWA, new String[] { type });
                            opDesc.addPartAttachmentDescription(part, attachmentDesc);
                        } else {
                            if (log.isDebugEnabled()) {
                                log.debug("Already created AttachmentDescription for part: " + part + " of type: " + type);
                            }
                        }
                    } else if (obj2 instanceof SOAPBody || obj2 instanceof SOAP12Body) {
                        if (log.isDebugEnabled()) {
                            log.debug("Found a body element with potential nested mime content");
                        }
                        // Flag whether there's a potential nested attachment.
                        if (isRequest) {
                            opDesc.setHasRequestSwaRefAttachments(true);
                        } else {
                            opDesc.setHasResponseSwaRefAttachments(true);
                        }
                    }
                }
            }
        }
    }
}
Also used : SOAPBody(javax.wsdl.extensions.soap.SOAPBody) MIMEContent(javax.wsdl.extensions.mime.MIMEContent) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) Iterator(java.util.Iterator) AttachmentDescription(org.apache.axis2.jaxws.description.AttachmentDescription) MIMEMultipartRelated(javax.wsdl.extensions.mime.MIMEMultipartRelated) MIMEPart(javax.wsdl.extensions.mime.MIMEPart)

Example 12 with Soap12Body

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

the class WSDL11ToAxisServiceBuilder method getPartsListFromSoapBody.

private List getPartsListFromSoapBody(List extensibilityElements) {
    List partsList = null;
    ExtensibilityElement extElement;
    for (Iterator iter = extensibilityElements.iterator(); iter.hasNext(); ) {
        extElement = (ExtensibilityElement) iter.next();
        if (log.isDebugEnabled()) {
            log.debug("Extensibility Element type is:" + extElement.getElementType());
            log.debug("Extensibility Element class is:" + extElement.getClass().getName());
        }
        // SOAP 1.1 body element found!
        if (extElement instanceof SOAPBody) {
            SOAPBody soapBody = (SOAPBody) extElement;
            partsList = soapBody.getParts();
        } else if (extElement instanceof SOAP12Body) {
            SOAP12Body soapBody = (SOAP12Body) extElement;
            partsList = soapBody.getParts();
        } else if (extElement instanceof MIMEMultipartRelated) {
            MIMEMultipartRelated minMimeMultipartRelated = (MIMEMultipartRelated) extElement;
            List mimePartsList = minMimeMultipartRelated.getMIMEParts();
            MIMEPart mimePart = null;
            Object object;
            List mimePartElements;
            ExtensibilityElement mimePartExtensibilityElement;
            for (Iterator mimePartsIter = mimePartsList.iterator(); mimePartsIter.hasNext(); ) {
                object = mimePartsIter.next();
                if (object instanceof MIMEPart) {
                    mimePart = (MIMEPart) object;
                    mimePartElements = mimePart.getExtensibilityElements();
                    for (Iterator mimePartElementsIter = mimePartElements.iterator(); mimePartElementsIter.hasNext(); ) {
                        mimePartExtensibilityElement = (ExtensibilityElement) mimePartElementsIter.next();
                        if (mimePartExtensibilityElement instanceof SOAPBody) {
                            SOAPBody soapBody = (SOAPBody) mimePartExtensibilityElement;
                            partsList = soapBody.getParts();
                        } else if (mimePartExtensibilityElement instanceof SOAP12Body) {
                            SOAP12Body soapBody = (SOAP12Body) mimePartExtensibilityElement;
                            partsList = soapBody.getParts();
                        }
                    }
                }
            }
        }
    }
    if (partsList == null) {
        log.debug("SOAP body parts have not been set. All the parts in the message were added to the message.");
    }
    return partsList;
}
Also used : SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) MIMEMultipartRelated(javax.wsdl.extensions.mime.MIMEMultipartRelated) MIMEPart(javax.wsdl.extensions.mime.MIMEPart)

Example 13 with Soap12Body

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

the class WSDL11ToAxisServiceBuilder method getNamespaceFromSoapBody.

private String getNamespaceFromSoapBody(List extensibilityElements) {
    ExtensibilityElement extElement;
    String namespace = null;
    for (Iterator iter = extensibilityElements.iterator(); iter.hasNext(); ) {
        extElement = (ExtensibilityElement) iter.next();
        // SOAP 1.1 body element found!
        if (extElement instanceof SOAPBody) {
            SOAPBody soapBody = (SOAPBody) extElement;
            namespace = soapBody.getNamespaceURI();
        } else if (extElement instanceof SOAP12Body) {
            SOAP12Body soapBody = (SOAP12Body) extElement;
            namespace = soapBody.getNamespaceURI();
        }
    }
    return namespace;
}
Also used : SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) Iterator(java.util.Iterator) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 14 with Soap12Body

use of com.helger.phase4.soap12.Soap12Body in project esb0 by karalus.

the class WSDL4JUtil method getInputElementQName.

@SuppressWarnings("unchecked")
public static QName getInputElementQName(BindingOperation bindingOperation, boolean soap12) {
    ElementExtensible bindingInput = bindingOperation.getBindingInput();
    // According to http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html
    MIMEMultipartRelated mmr = getExtensibilityElement(bindingInput, MIMEMultipartRelated.class);
    if (mmr != null) {
        bindingInput = (ElementExtensible) mmr.getMIMEParts().get(0);
    }
    List<String> parts;
    if (soap12) {
        SOAP12Body body = getExtensibilityElement(bindingInput, SOAP12Body.class);
        if (body == null) {
            throw new IllegalArgumentException("BindingOperation has no SOAP 1.2 Body: " + bindingOperation.getName());
        }
        parts = body.getParts();
    } else {
        SOAPBody body = getExtensibilityElement(bindingInput, SOAPBody.class);
        if (body == null) {
            throw new IllegalArgumentException("BindingOperation has no SOAP 1.1 Body: " + bindingOperation.getName());
        }
        parts = body.getParts();
    }
    Message message = bindingOperation.getOperation().getInput().getMessage();
    Part part = parts == null || parts.isEmpty() ? (Part) message.getParts().values().iterator().next() : message.getPart(parts.get(0));
    return part.getElementName();
}
Also used : SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) Message(javax.wsdl.Message) ElementExtensible(javax.wsdl.extensions.ElementExtensible) Part(javax.wsdl.Part) MIMEMultipartRelated(javax.wsdl.extensions.mime.MIMEMultipartRelated)

Aggregations

SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)12 SOAPBody (javax.wsdl.extensions.soap.SOAPBody)8 BindingOperation (javax.wsdl.BindingOperation)6 Iterator (java.util.Iterator)5 QName (javax.xml.namespace.QName)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 BindingInput (javax.wsdl.BindingInput)4 Part (javax.wsdl.Part)4 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)4 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)4 Binding (javax.wsdl.Binding)3 BindingOutput (javax.wsdl.BindingOutput)3 Message (javax.wsdl.Message)3 MIMEMultipartRelated (javax.wsdl.extensions.mime.MIMEMultipartRelated)3 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)3 Soap12Body (com.helger.phase4.soap12.Soap12Body)2 Soap12Envelope (com.helger.phase4.soap12.Soap12Envelope)2 Soap12Header (com.helger.phase4.soap12.Soap12Header)2