Search in sources :

Example 1 with ElementExtensible

use of javax.wsdl.extensions.ElementExtensible 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 ElementExtensible

use of javax.wsdl.extensions.ElementExtensible 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

ElementExtensible (javax.wsdl.extensions.ElementExtensible)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Message (javax.wsdl.Message)1 Part (javax.wsdl.Part)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 MIMEMultipartRelated (javax.wsdl.extensions.mime.MIMEMultipartRelated)1 SOAPBody (javax.wsdl.extensions.soap.SOAPBody)1 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)1 SOAP12Header (javax.wsdl.extensions.soap12.SOAP12Header)1