Search in sources :

Example 1 with WSDLOperation

use of org.wso2.carbon.apimgt.impl.wsdl.model.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.impl.wsdl.model.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.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getSOAPOperation.

/**
 * Retrieves WSDL operation given the soap binding operation
 *
 * @param bindingOperation {@link BindingOperation} object
 * @return a set of {@link WSDLOperation} defined in the provided Binding
 */
private WSDLSOAPOperation getSOAPOperation(BindingOperation bindingOperation) throws APIMgtWSDLException {
    WSDLSOAPOperation wsdlOperation = null;
    for (Object boExtElement : bindingOperation.getExtensibilityElements()) {
        if (boExtElement instanceof SOAPOperation) {
            SOAPOperation soapOperation = (SOAPOperation) boExtElement;
            wsdlOperation = new WSDLSOAPOperation();
            wsdlOperation.setName(bindingOperation.getName());
            wsdlOperation.setSoapAction(soapOperation.getSoapActionURI());
            wsdlOperation.setTargetNamespace(getTargetNamespace(bindingOperation));
            wsdlOperation.setStyle(soapOperation.getStyle());
            wsdlOperation.setInputParameterModel(getSoapInputParameterModel(bindingOperation));
            wsdlOperation.setOutputParameterModel(getSoapOutputParameterModel(bindingOperation));
            wsdlOperation.setMessageType(getSoapMessageType(bindingOperation));
        } else if (boExtElement instanceof SOAP12Operation) {
            SOAP12Operation soapOperation = (SOAP12Operation) boExtElement;
            wsdlOperation = new WSDLSOAPOperation();
            wsdlOperation.setName(bindingOperation.getName());
            wsdlOperation.setSoapAction(soapOperation.getSoapActionURI());
            wsdlOperation.setTargetNamespace(getTargetNamespace(bindingOperation));
            wsdlOperation.setStyle(soapOperation.getStyle());
            wsdlOperation.setInputParameterModel(getSoapInputParameterModel(bindingOperation));
            wsdlOperation.setOutputParameterModel(getSoapOutputParameterModel(bindingOperation));
            wsdlOperation.setMessageType(getSoapMessageType(bindingOperation));
        }
    }
    return wsdlOperation;
}
Also used : WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation)

Example 4 with WSDLOperation

use of org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getSoapBindingOperations.

/**
 * 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<WSDLSOAPOperation> getSoapBindingOperations(Definition definition) throws APIMgtWSDLException {
    Set<WSDLSOAPOperation> allOperations = new HashSet<>();
    for (Object bindingObj : definition.getAllBindings().values()) {
        if (bindingObj instanceof Binding) {
            Binding binding = (Binding) bindingObj;
            Set<WSDLSOAPOperation> operations = getSOAPBindingOperations(binding);
            allOperations.addAll(operations);
        }
    }
    return allOperations;
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) HashSet(java.util.HashSet)

Example 5 with WSDLOperation

use of org.wso2.carbon.apimgt.impl.wsdl.model.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)

Aggregations

WSDLOperation (org.wso2.carbon.apimgt.core.models.WSDLOperation)6 HashSet (java.util.HashSet)5 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)3 WSDLSOAPOperation (org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation)3 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 HTTPBinding (javax.wsdl.extensions.http.HTTPBinding)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Definition (javax.wsdl.Definition)1 Message (javax.wsdl.Message)1 HTTPOperation (javax.wsdl.extensions.http.HTTPOperation)1 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)1 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)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