Search in sources :

Example 11 with BindingInput

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

the class WSDLAwareSOAPProcessor method parseRequest.

public WSDLAwareMessage parseRequest() throws AxisFault {
    /**
     * I assume that local part of the Axis Operation's name is always equal to
     * the operation name in the WSDL.
     */
    BindingOperation bindingOp = wsdlBinding.getBindingOperation(wsdlBinding.getPortType().getOperation(inMessageCtx.getAxisOperation().getName().getLocalPart(), null, null).getName(), null, null);
    if (bindingOp == null) {
        throw new AxisFault("WSDL binding operation not found for service: " + serviceName.getLocalPart() + " port: " + portName);
    }
    BindingInput bindingInput = bindingOp.getBindingInput();
    if (bindingInput == null) {
        throw new AxisFault("BindingInput not found for service: " + serviceName.getLocalPart() + " port: " + portName);
    }
    return processMessageParts(bindingInput);
}
Also used : AxisFault(org.apache.axis2.AxisFault) BindingOperation(javax.wsdl.BindingOperation) BindingInput(javax.wsdl.BindingInput)

Example 12 with BindingInput

use of javax.wsdl.BindingInput 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 13 with BindingInput

use of javax.wsdl.BindingInput in project tomee by apache.

the class JaxRpcServiceInfoBuilder method getStyle.

private BindingStyle getStyle(Binding binding) throws OpenEJBException {
    SOAPBinding soapBinding = getExtensibilityElement(SOAPBinding.class, binding.getExtensibilityElements());
    String styleString = soapBinding.getStyle();
    BindingInput bindingInput = ((BindingOperation) binding.getBindingOperations().get(0)).getBindingInput();
    SOAPBody soapBody = getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
    String useString = soapBody.getUse();
    BindingStyle bindingStyle = BindingStyle.getBindingStyle(styleString, useString);
    return bindingStyle;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) BindingInput(javax.wsdl.BindingInput)

Example 14 with BindingInput

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

the class UniqueBodyPartsValidator method isValid.

public boolean isValid() {
    Collection<Binding> bindings = CastUtils.cast(def.getAllBindings().values());
    for (Binding binding : bindings) {
        uniqueBodyPartsMap = new HashMap<>();
        List<BindingOperation> ops = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation op : ops) {
            Operation operation = op.getOperation();
            if (operation != null && operation.getInput() != null) {
                Message inMessage = operation.getInput().getMessage();
                BindingInput bin = op.getBindingInput();
                Set<String> headers = new HashSet<>();
                if (bin != null) {
                    List<ExtensibilityElement> lst = CastUtils.cast(bin.getExtensibilityElements());
                    for (ExtensibilityElement ext : lst) {
                        if (!(ext instanceof SOAPHeader)) {
                            continue;
                        }
                        SOAPHeader header = (SOAPHeader) ext;
                        if (!header.getMessage().equals(inMessage.getQName())) {
                            continue;
                        }
                        headers.add(header.getPart());
                    }
                }
                if (inMessage != null && !isUniqueBodyPart(operation.getName(), inMessage, headers, binding.getQName())) {
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : Binding(javax.wsdl.Binding) Message(javax.wsdl.Message) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingInput(javax.wsdl.BindingInput) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) BindingOperation(javax.wsdl.BindingOperation) SOAPHeader(javax.wsdl.extensions.soap.SOAPHeader) HashSet(java.util.HashSet)

Example 15 with BindingInput

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

the class WSDLToXMLProcessor method getBindingInput.

private BindingInput getBindingInput(Input input, String operationName) throws ToolException {
    BindingInput bi = wsdlDefinition.createBindingInput();
    bi.setName(input.getName());
    // This ext element in some scenario is optional, but if provided, won't cause error
    bi.addExtensibilityElement(getXMLBody(BindingInput.class, operationName));
    return bi;
}
Also used : BindingInput(javax.wsdl.BindingInput)

Aggregations

BindingInput (javax.wsdl.BindingInput)22 BindingOperation (javax.wsdl.BindingOperation)16 Binding (javax.wsdl.Binding)7 QName (javax.xml.namespace.QName)7 BindingOutput (javax.wsdl.BindingOutput)6 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)6 SOAPBody (javax.wsdl.extensions.soap.SOAPBody)6 ToolException (org.apache.cxf.tools.common.ToolException)5 Test (org.junit.Test)5 File (java.io.File)4 Message (javax.wsdl.Message)4 Operation (javax.wsdl.Operation)4 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)4 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)4 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)4 SoapBody (org.apache.cxf.binding.soap.wsdl.extensions.SoapBody)4 SoapOperation (org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation)4 ArrayList (java.util.ArrayList)3 Input (javax.wsdl.Input)3 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)3