Search in sources :

Example 6 with BindingOutput

use of javax.wsdl.BindingOutput 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)

Example 7 with BindingOutput

use of javax.wsdl.BindingOutput in project carbon-business-process by wso2.

the class SOAPUtils method parseResponseFromRESTService.

public static org.apache.ode.bpel.iapi.Message parseResponseFromRESTService(BPELMessageContext partnerInvocationContext, PartnerRoleMessageExchange odePartnerMex) {
    org.apache.ode.bpel.iapi.Message messageToODE = odePartnerMex.createMessage(odePartnerMex.getOperation().getOutput().getMessage().getQName());
    BindingOperation bindingOp = getBindingOperation(partnerInvocationContext, odePartnerMex.getOperationName());
    BindingOutput bindingOutPut = getBindingOutPut(bindingOp);
    javax.wsdl.extensions.mime.MIMEContent mimeContent = getFirstExtensibilityElement(bindingOutPut, MIMEContent.class);
    if (mimeContent != null) {
        SOAPEnvelope soapEnv = partnerInvocationContext.getOutMessageContext().getEnvelope();
        Iterator childElementsItr = soapEnv.getBody().getChildElements();
        while (childElementsItr.hasNext()) {
            OMNode child = (OMNode) childElementsItr.next();
            if (child.getType() == OMNode.ELEMENT_NODE) {
                Document doc = DOMUtils.newDocument();
                Element domPart = doc.createElementNS(null, mimeContent.getPart());
                domPart.appendChild(doc.importNode(OMUtils.toDOM((OMElement) child), true));
                messageToODE.setPart(mimeContent.getPart(), domPart);
                return messageToODE;
            }
        }
    }
    throw new IllegalArgumentException("WSO2 BPS only support HTTP binding with mime output.");
}
Also used : BindingOutput(javax.wsdl.BindingOutput) MIMEContent(javax.wsdl.extensions.mime.MIMEContent) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) Document(org.w3c.dom.Document) SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) OMNode(org.apache.axiom.om.OMNode) Node(org.w3c.dom.Node) OMNode(org.apache.axiom.om.OMNode) BindingOperation(javax.wsdl.BindingOperation) Iterator(java.util.Iterator)

Example 8 with BindingOutput

use of javax.wsdl.BindingOutput in project carbon-business-process by wso2.

the class SOAPUtils method createSOAPResponse.

/**
 * Create SOAP Response message from response returned byBPELServer ODE engine.
 *
 * @param bpelMessageContext DTO contains details on current messageflow.
 * @param odeMessageExchange ODE MyRoleMessageExchange contains data on the current process
 *                           invocation
 * @throws AxisFault in case of a error while creating SOAP response.
 */
public static void createSOAPResponse(final BPELMessageContext bpelMessageContext, final MyRoleMessageExchange odeMessageExchange) throws AxisFault {
    checkForNullValuesInResponse(bpelMessageContext, odeMessageExchange);
    BindingOperation bindingOp = getBindingOperation(bpelMessageContext, odeMessageExchange.getOperationName());
    BindingOutput bindingOutput = getBindingOutPut(bindingOp);
    SOAPEnvelope soapEnv = bpelMessageContext.getOutMessageContext().getEnvelope();
    if (soapEnv == null) {
        soapEnv = bpelMessageContext.getSoapFactoryForCurrentMessageFlow().getDefaultEnvelope();
        bpelMessageContext.getOutMessageContext().setEnvelope(soapEnv);
    }
    populateSOAPHeaders(odeMessageExchange.getResponse(), soapEnv, bpelMessageContext.getSoapFactoryForCurrentMessageFlow(), getSOAPHeaders(bindingOutput), odeMessageExchange.getOperation());
    populateSOAPBody(soapEnv, bindingOutput, bpelMessageContext.isSoap12(), bpelMessageContext.getSoapFactoryForCurrentMessageFlow(), odeMessageExchange.getOperation(), odeMessageExchange.getOperation().getOutput().getMessage(), odeMessageExchange.getResponse(), bpelMessageContext.isRPCStyleOperation(), false);
}
Also used : BindingOperation(javax.wsdl.BindingOperation) BindingOutput(javax.wsdl.BindingOutput) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 9 with BindingOutput

use of javax.wsdl.BindingOutput in project ofbiz-framework by apache.

the class ModelService method getWSDL.

public void getWSDL(Definition def, String locationURI) throws WSDLException {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = null;
    Document document = null;
    try {
        builder = factory.newDocumentBuilder();
        document = builder.newDocument();
    } catch (Exception e) {
        throw new WSDLException("can not create WSDL", module);
    }
    def.setTypes(this.getTypes(document, def));
    // set the IN parameters
    Input input = def.createInput();
    Set<String> inParam = this.getInParamNames();
    Message inMessage = def.createMessage();
    inMessage.setQName(new QName(TNS, this.name + "Request"));
    inMessage.setUndefined(false);
    Part parametersPart = def.createPart();
    parametersPart.setName("map-Map");
    parametersPart.setTypeName(new QName(TNS, "map-Map"));
    inMessage.addPart(parametersPart);
    Element documentation = document.createElement("wsdl:documentation");
    for (String paramName : inParam) {
        ModelParam param = this.getParam(paramName);
        if (!param.internal) {
            Part part = param.getWSDLPart(def);
            Element attribute = document.createElement("attribute");
            attribute.setAttribute("name", paramName);
            attribute.setAttribute("type", part.getTypeName().getLocalPart());
            attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
            attribute.setAttribute("java-class", param.type);
            attribute.setAttribute("optional", Boolean.toString(param.optional));
            documentation.appendChild(attribute);
        }
    }
    Element usernameAttr = document.createElement("attribute");
    usernameAttr.setAttribute("name", "login.username");
    usernameAttr.setAttribute("type", "std-String");
    usernameAttr.setAttribute("namespace", TNS);
    usernameAttr.setAttribute("java-class", String.class.getName());
    usernameAttr.setAttribute("optional", Boolean.toString(!this.auth));
    documentation.appendChild(usernameAttr);
    Element passwordAttr = document.createElement("attribute");
    passwordAttr.setAttribute("name", "login.password");
    passwordAttr.setAttribute("type", "std-String");
    passwordAttr.setAttribute("namespace", TNS);
    passwordAttr.setAttribute("java-class", String.class.getName());
    passwordAttr.setAttribute("optional", Boolean.toString(!this.auth));
    documentation.appendChild(passwordAttr);
    parametersPart.setDocumentationElement(documentation);
    def.addMessage(inMessage);
    input.setMessage(inMessage);
    // set the OUT parameters
    Output output = def.createOutput();
    Set<String> outParam = this.getOutParamNames();
    Message outMessage = def.createMessage();
    outMessage.setQName(new QName(TNS, this.name + "Response"));
    outMessage.setUndefined(false);
    Part resultsPart = def.createPart();
    resultsPart.setName("map-Map");
    resultsPart.setTypeName(new QName(TNS, "map-Map"));
    outMessage.addPart(resultsPart);
    documentation = document.createElement("wsdl:documentation");
    for (String paramName : outParam) {
        ModelParam param = this.getParam(paramName);
        if (!param.internal) {
            Part part = param.getWSDLPart(def);
            Element attribute = document.createElement("attribute");
            attribute.setAttribute("name", paramName);
            attribute.setAttribute("type", part.getTypeName().getLocalPart());
            attribute.setAttribute("namespace", part.getTypeName().getNamespaceURI());
            attribute.setAttribute("java-class", param.type);
            attribute.setAttribute("optional", Boolean.toString(param.optional));
            documentation.appendChild(attribute);
        }
    }
    resultsPart.setDocumentationElement(documentation);
    def.addMessage(outMessage);
    output.setMessage(outMessage);
    // set port type
    Operation operation = def.createOperation();
    operation.setName(this.name);
    operation.setUndefined(false);
    operation.setOutput(output);
    operation.setInput(input);
    PortType portType = def.createPortType();
    portType.setQName(new QName(TNS, this.name + "PortType"));
    portType.addOperation(operation);
    portType.setUndefined(false);
    def.addPortType(portType);
    // SOAP binding
    SOAPBinding soapBinding = new SOAPBindingImpl();
    soapBinding.setStyle("rpc");
    soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    Binding binding = def.createBinding();
    binding.setQName(new QName(TNS, this.name + "SoapBinding"));
    binding.setPortType(portType);
    binding.setUndefined(false);
    binding.addExtensibilityElement(soapBinding);
    BindingOperation bindingOperation = def.createBindingOperation();
    bindingOperation.setName(operation.getName());
    bindingOperation.setOperation(operation);
    SOAPBody soapBody = new SOAPBodyImpl();
    soapBody.setUse("literal");
    soapBody.setNamespaceURI(TNS);
    soapBody.setEncodingStyles(UtilMisc.toList("http://schemas.xmlsoap.org/soap/encoding/"));
    BindingOutput bindingOutput = def.createBindingOutput();
    bindingOutput.addExtensibilityElement(soapBody);
    bindingOperation.setBindingOutput(bindingOutput);
    BindingInput bindingInput = def.createBindingInput();
    bindingInput.addExtensibilityElement(soapBody);
    bindingOperation.setBindingInput(bindingInput);
    SOAPOperation soapOperation = new SOAPOperationImpl();
    // soapAction should be set to the location of the SOAP URI, or Visual Studio won't construct the correct SOAP message
    soapOperation.setSoapActionURI(locationURI);
    // this is the RPC/literal style.  See http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
    // this parameter is necessary or Apache Synapse won't recognize the WSDL
    soapOperation.setStyle("rpc");
    bindingOperation.addExtensibilityElement(soapOperation);
    binding.addBindingOperation(bindingOperation);
    def.addBinding(binding);
    // Service port
    Port port = def.createPort();
    port.setBinding(binding);
    port.setName(this.name + "Port");
    if (locationURI != null) {
        SOAPAddress soapAddress = new SOAPAddressImpl();
        soapAddress.setLocationURI(locationURI);
        port.addExtensibilityElement(soapAddress);
    }
    Service service = def.createService();
    service.setQName(new QName(TNS, this.name));
    service.addPort(port);
    def.addService(service);
}
Also used : SOAPAddressImpl(com.ibm.wsdl.extensions.soap.SOAPAddressImpl) BindingOutput(javax.wsdl.BindingOutput) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) Message(javax.wsdl.Message) Element(org.w3c.dom.Element) Port(javax.wsdl.Port) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAPBodyImpl(com.ibm.wsdl.extensions.soap.SOAPBodyImpl) Document(org.w3c.dom.Document) BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) BindingOperation(javax.wsdl.BindingOperation) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Binding(javax.wsdl.Binding) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) Service(javax.wsdl.Service) SOAPOperationImpl(com.ibm.wsdl.extensions.soap.SOAPOperationImpl) GeneralException(org.apache.ofbiz.base.util.GeneralException) NoSuchElementException(java.util.NoSuchElementException) WSDLException(javax.wsdl.WSDLException) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Part(javax.wsdl.Part) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) SOAPBindingImpl(com.ibm.wsdl.extensions.soap.SOAPBindingImpl) PortType(javax.wsdl.PortType)

Example 10 with BindingOutput

use of javax.wsdl.BindingOutput in project cxf by apache.

the class WSDLToXMLProcessor method getBindingOutput.

private BindingOutput getBindingOutput(Output output, String operationName) throws ToolException {
    BindingOutput bo = wsdlDefinition.createBindingOutput();
    bo.setName(output.getName());
    bo.addExtensibilityElement(getXMLBody(BindingOutput.class, operationName));
    return bo;
}
Also used : BindingOutput(javax.wsdl.BindingOutput)

Aggregations

BindingOutput (javax.wsdl.BindingOutput)15 BindingOperation (javax.wsdl.BindingOperation)9 BindingInput (javax.wsdl.BindingInput)6 ArrayList (java.util.ArrayList)3 Message (javax.wsdl.Message)3 Operation (javax.wsdl.Operation)3 Output (javax.wsdl.Output)3 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)3 SOAPBody (javax.wsdl.extensions.soap.SOAPBody)3 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)3 Input (javax.wsdl.Input)2 WSDLException (javax.wsdl.WSDLException)2 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)2 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)2 QName (javax.xml.namespace.QName)2 OMNode (org.apache.axiom.om.OMNode)2 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)2