Search in sources :

Example 1 with WSDLOperation

use of org.wso2.carbon.apimgt.core.models.WSDLOperation in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getHttpBindingOperations.

/**
 * Retrieves all the operations defined in the provided Binding.
 *
 * @param binding WSDL binding
 * @return a set of {@link WSDLOperation} defined in the provided Binding
 */
private Set<WSDLOperation> getHttpBindingOperations(Binding binding) {
    Set<WSDLOperation> allBindingOperations = new HashSet<>();
    if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
        if (binding.getExtensibilityElements().get(0) instanceof HTTPBinding) {
            HTTPBinding httpBinding = (HTTPBinding) binding.getExtensibilityElements().get(0);
            String verb = httpBinding.getVerb();
            for (Object opObj : binding.getBindingOperations()) {
                if (opObj instanceof BindingOperation) {
                    BindingOperation bindingOperation = (BindingOperation) opObj;
                    WSDLOperation wsdlOperation = getOperation(bindingOperation, verb);
                    if (wsdlOperation != null) {
                        allBindingOperations.add(wsdlOperation);
                    }
                }
            }
        }
    }
    return allBindingOperations;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) HashSet(java.util.HashSet)

Example 2 with WSDLOperation

use of org.wso2.carbon.apimgt.core.models.WSDLOperation in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getHttpBindingOperations.

/**
 * Retrieves all the operations defined in the provided WSDL definition.
 *
 * @param definition WSDL Definition
 * @return a set of {@link WSDLOperation} defined in the provided WSDL definition
 */
private Set<WSDLOperation> getHttpBindingOperations(Definition definition) {
    Set<WSDLOperation> allOperations = new HashSet<>();
    for (Object bindingObj : definition.getAllBindings().values()) {
        if (bindingObj instanceof Binding) {
            Binding binding = (Binding) bindingObj;
            Set<WSDLOperation> operations = getHttpBindingOperations(binding);
            allOperations.addAll(operations);
        }
    }
    return allOperations;
}
Also used : HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation) HashSet(java.util.HashSet)

Example 3 with WSDLOperation

use of org.wso2.carbon.apimgt.core.models.WSDLOperation in project carbon-business-process by wso2.

the class SOAPUtils method handleSOAPHeaderElementsInBindingOperation.

@SuppressWarnings("unchecked")
private static void handleSOAPHeaderElementsInBindingOperation(SOAPEnvelope soapEnvelope, SOAPFactory soapFactory, org.apache.ode.bpel.iapi.Message messageFromOde, Operation wsdlOperation, final javax.wsdl.extensions.soap.SOAPHeader soapHeaderElementDefinition) throws BPELFault {
    Map<String, Node> headerParts = messageFromOde.getHeaderParts();
    Message responseMessageDefinition = wsdlOperation.getOutput() != null ? wsdlOperation.getOutput().getMessage() : null;
    // If there isn't a message attribute in header element definition or if the
    // message attribute value is equal to the response message QName, then this
    // header element is part of the actual payload.
    // Refer SOAP Binding specification at http://www.w3.org/TR/wsdl#_soap-b.
    final boolean isHeaderElementAPartOfPayload = soapHeaderElementDefinition.getMessage() == null || ((wsdlOperation.getStyle() != OperationType.ONE_WAY) && soapHeaderElementDefinition.getMessage().equals(responseMessageDefinition.getQName()));
    if (soapHeaderElementDefinition.getPart() == null) {
        // Part information not found. Ignoring this header definition.
        return;
    }
    if (isHeaderElementAPartOfPayload && (responseMessageDefinition != null && responseMessageDefinition.getPart(soapHeaderElementDefinition.getPart()) == null)) {
        // we should throw a exception.
        throw new BPELFault("SOAP Header Element Definition refer unknown part.");
    }
    Element partElement = null;
    if (headerParts.size() > 0 && isHeaderElementAPartOfPayload) {
        try {
            partElement = (Element) headerParts.get(soapHeaderElementDefinition.getPart());
        } catch (ClassCastException e) {
            throw new BPELFault("SOAP Header must be a DOM Element.", e);
        }
    }
    // message payload. This is because, some headers will provided by SOAP engine.
    if (partElement == null && isHeaderElementAPartOfPayload) {
        if (messageFromOde.getPart(soapHeaderElementDefinition.getPart()) != null) {
            partElement = messageFromOde.getPart(soapHeaderElementDefinition.getPart());
        } else {
            throw new BPELFault("Missing Required part in response message.");
        }
    }
    // and can be found and extracted from the odeMessage object
    if (partElement == null && messageFromOde.getParts().size() > 0 && !isHeaderElementAPartOfPayload) {
        try {
            partElement = (Element) messageFromOde.getPart(soapHeaderElementDefinition.getPart());
        } catch (ClassCastException e) {
            throw new BPELFault("Soap header must be an element" + messageFromOde.getPart(soapHeaderElementDefinition.getPart()));
        }
    }
    // just ignore this case.
    if (partElement == null) {
        return;
    }
    org.apache.axiom.soap.SOAPHeader soapHeader = soapEnvelope.getHeader();
    if (soapHeader == null) {
        soapHeader = soapFactory.createSOAPHeader(soapEnvelope);
    }
    OMElement omPart = OMUtils.toOM(partElement, soapFactory);
    for (Iterator<OMNode> i = omPart.getChildren(); i.hasNext(); ) {
        soapHeader.addChild(i.next());
    }
}
Also used : Message(javax.wsdl.Message) BPELFault(org.wso2.carbon.bpel.core.ode.integration.BPELFault) OMNode(org.apache.axiom.om.OMNode) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) OMElement(org.apache.axiom.om.OMElement) SOAPHeader(org.apache.axiom.soap.SOAPHeader) OMNode(org.apache.axiom.om.OMNode)

Example 4 with WSDLOperation

use of org.wso2.carbon.apimgt.core.models.WSDLOperation in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getWsdlInfo.

@Override
public WSDLInfo getWsdlInfo() throws APIMgtWSDLException {
    WSDLInfo wsdlInfo = new WSDLInfo();
    Map<String, String> endpointsMap = getEndpoints();
    Set<WSDLOperation> operations = getHttpBindingOperations();
    wsdlInfo.setEndpoints(endpointsMap);
    wsdlInfo.setVersion(APIMgtConstants.WSDLConstants.WSDL_VERSION_11);
    if (!operations.isEmpty()) {
        wsdlInfo.setHasHttpBindingOperations(true);
        wsdlInfo.setHttpBindingOperations(operations);
    } else {
        wsdlInfo.setHasHttpBindingOperations(false);
    }
    wsdlInfo.setHasSoapBindingOperations(hasSoapBindingOperations());
    return wsdlInfo;
}
Also used : WSDLInfo(org.wso2.carbon.apimgt.core.models.WSDLInfo) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation)

Example 5 with WSDLOperation

use of org.wso2.carbon.apimgt.core.models.WSDLOperation in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getHttpBindingOperations.

/**
 * Retrieves all the operations defined in WSDL(s).
 *
 * @return a set of {@link WSDLOperation} defined in WSDL(s)
 */
private Set<WSDLOperation> getHttpBindingOperations() {
    if (wsdlDefinition != null) {
        return getHttpBindingOperations(wsdlDefinition);
    } else {
        Set<WSDLOperation> allOperations = new HashSet<>();
        for (Definition definition : pathToDefinitionMap.values()) {
            Set<WSDLOperation> operations = getHttpBindingOperations(definition);
            allOperations.addAll(operations);
        }
        return allOperations;
    }
}
Also used : Definition(javax.wsdl.Definition) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation) HashSet(java.util.HashSet)

Aggregations

WSDLOperation (org.wso2.carbon.apimgt.core.models.WSDLOperation)6 HashSet (java.util.HashSet)3 HTTPBinding (javax.wsdl.extensions.http.HTTPBinding)2 HashMap (java.util.HashMap)1 Binding (javax.wsdl.Binding)1 BindingOperation (javax.wsdl.BindingOperation)1 Definition (javax.wsdl.Definition)1 Message (javax.wsdl.Message)1 HTTPOperation (javax.wsdl.extensions.http.HTTPOperation)1 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)1 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)1 OMElement (org.apache.axiom.om.OMElement)1 OMNode (org.apache.axiom.om.OMNode)1 SOAPHeader (org.apache.axiom.soap.SOAPHeader)1 Element (org.w3c.dom.Element)1 Node (org.w3c.dom.Node)1 URITemplateParam (org.wso2.carbon.apimgt.core.models.URITemplateParam)1 UriTemplate (org.wso2.carbon.apimgt.core.models.UriTemplate)1 WSDLInfo (org.wso2.carbon.apimgt.core.models.WSDLInfo)1 WSDLOperationParam (org.wso2.carbon.apimgt.core.models.WSDLOperationParam)1