Search in sources :

Example 1 with SOAP12Operation

use of javax.wsdl.extensions.soap12.SOAP12Operation in project tdi-studio-se by Talend.

the class ComponentBuilder method buildOperation.

private OperationInfo buildOperation(OperationInfo operationInfo, BindingOperation bindingOper) {
    Operation oper = bindingOper.getOperation();
    operationInfo.setTargetMethodName(oper.getName());
    Vector operElems = findExtensibilityElement(bindingOper.getExtensibilityElements(), "operation");
    ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
    if (operElem != null && operElem instanceof SOAPOperation) {
        SOAPOperation soapOperation = (SOAPOperation) operElem;
        operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
    } else if (operElem != null && operElem instanceof SOAP12Operation) {
        SOAP12Operation soapOperation = (SOAP12Operation) operElem;
        operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
    }
    BindingInput bindingInput = bindingOper.getBindingInput();
    BindingOutput bindingOutput = bindingOper.getBindingOutput();
    Vector bodyElems = findExtensibilityElement(bindingInput.getExtensibilityElements(), "body");
    ExtensibilityElement bodyElem = (ExtensibilityElement) bodyElems.elementAt(0);
    if (bodyElem != null && bodyElem instanceof SOAPBody) {
        SOAPBody soapBody = (SOAPBody) bodyElem;
        List styles = soapBody.getEncodingStyles();
        String encodingStyle = null;
        if (styles != null) {
            encodingStyle = styles.get(0).toString();
        }
        if (encodingStyle == null) {
            encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
        }
        operationInfo.setEncodingStyle(encodingStyle.toString());
        operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
    } else if (bodyElem != null && bodyElem instanceof SOAP12Body) {
        SOAP12Body soapBody = (SOAP12Body) bodyElem;
        String encodingStyle = null;
        if (soapBody.getEncodingStyle() != null) {
            encodingStyle = soapBody.getEncodingStyle().toString();
        }
        if (encodingStyle == null) {
            encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
        }
        operationInfo.setEncodingStyle(encodingStyle.toString());
        operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
    }
    Input inDef = oper.getInput();
    if (inDef != null) {
        Message inMsg = inDef.getMessage();
        if (inMsg != null) {
            operationInfo.setInputMessageName(inMsg.getQName().getLocalPart());
            getParameterFromMessage(operationInfo, inMsg, 1);
            operationInfo.setInmessage(inMsg);
        }
    }
    Output outDef = oper.getOutput();
    if (outDef != null) {
        Message outMsg = outDef.getMessage();
        if (outMsg != null) {
            operationInfo.setOutputMessageName(outMsg.getQName().getLocalPart());
            getParameterFromMessage(operationInfo, outMsg, 2);
            operationInfo.setOutmessage(outMsg);
        }
    }
    return operationInfo;
}
Also used : SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingOutput(javax.wsdl.BindingOutput) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) Message(javax.wsdl.Message) Operation(javax.wsdl.Operation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingInput(javax.wsdl.BindingInput) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector)

Example 2 with SOAP12Operation

use of javax.wsdl.extensions.soap12.SOAP12Operation in project cxf by apache.

the class WSDLToSoapProcessorTest method testNewSoap12Binding.

@Test
public void testNewSoap12Binding() throws Exception {
    String[] args = new String[] { "-i", "Greeter", "-soap12", "-b", "Greeter_SOAP12Binding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap12_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_soap12_nobinding.wsdl") };
    WSDLToSoap.main(args);
    File outputFile = new File(output, "hello_world_soap12_newbinding.wsdl");
    assertTrue("New wsdl file is not generated", outputFile.exists());
    assertTrue("Generated file is empty!", outputFile.length() > 0);
    WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
    processor.setEnvironment(env);
    try {
        processor.parseWSDL(outputFile.getAbsolutePath());
        Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_SOAP12Binding"));
        if (binding == null) {
            fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
        }
        for (Object obj : binding.getExtensibilityElements()) {
            assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
            assertTrue(obj instanceof SOAP12Binding);
            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
            assertNotNull(soapBinding);
            assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
            assertTrue(WSDLConstants.NS_SOAP_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
        }
        BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
        if (bo == null) {
            fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
        }
        for (Object obj : bo.getExtensibilityElements()) {
            assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
            assertTrue(obj instanceof SOAP12Operation);
            SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
            assertNotNull(soapOperation);
            assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
        }
        BindingInput bi = bo.getBindingInput();
        for (Object obj : bi.getExtensibilityElements()) {
            assertTrue(SOAPBindingUtil.isSOAPBody(obj));
            assertTrue(obj instanceof SOAP12Body);
            SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
            assertNotNull(soapBody);
            assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
        }
    } catch (ToolException e) {
        fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
    }
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) QName(javax.xml.namespace.QName) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) BindingInput(javax.wsdl.BindingInput) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) BindingOperation(javax.wsdl.BindingOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) Test(org.junit.Test)

Example 3 with SOAP12Operation

use of javax.wsdl.extensions.soap12.SOAP12Operation in project cxf by apache.

the class WSDLToSoapProcessorTest method testAddSoap12Binding.

@Test
public void testAddSoap12Binding() throws Exception {
    String[] args = new String[] { "-i", "Greeter", "-soap12", "-b", "Greeter_SOAP12Binding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap12_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_soap12.wsdl") };
    WSDLToSoap.main(args);
    File outputFile = new File(output, "hello_world_soap12_newbinding.wsdl");
    assertTrue("New wsdl file is not generated", outputFile.exists());
    WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
    processor.setEnvironment(env);
    try {
        processor.parseWSDL(outputFile.getAbsolutePath());
        Binding binding = processor.getWSDLDefinition().getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), "Greeter_SOAP12Binding"));
        if (binding == null) {
            fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
        }
        for (Object obj : binding.getExtensibilityElements()) {
            assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
            assertTrue(obj instanceof SOAP12Binding);
            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
            assertNotNull(soapBinding);
            assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
        }
        BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
        if (bo == null) {
            fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
        }
        for (Object obj : bo.getExtensibilityElements()) {
            assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
            assertTrue(obj instanceof SOAP12Operation);
            SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
            assertNotNull(soapOperation);
            assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
        }
        BindingInput bi = bo.getBindingInput();
        for (Object obj : bi.getExtensibilityElements()) {
            assertTrue(SOAPBindingUtil.isSOAPBody(obj));
            assertTrue(obj instanceof SOAP12Body);
            SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
            assertNotNull(soapBody);
            assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
        }
        bo = binding.getBindingOperation("pingMe", null, null);
        assertNotNull(bo);
        Iterator<?> it = bo.getExtensibilityElements().iterator();
        assertTrue(it != null && it.hasNext());
        assertTrue(it.next() instanceof SOAP12Operation);
        it = bo.getBindingInput().getExtensibilityElements().iterator();
        assertTrue(it != null && it.hasNext());
        assertTrue(it.next() instanceof SOAP12Body);
        it = bo.getBindingOutput().getExtensibilityElements().iterator();
        assertTrue(it != null && it.hasNext());
        assertTrue(it.next() instanceof SOAP12Body);
        Map<?, ?> faults = bo.getBindingFaults();
        assertTrue(faults != null && faults.size() == 1);
        Object bf = faults.get("pingMeFault");
        assertNotNull(bf);
        assertTrue(bf instanceof BindingFault);
        assertEquals("pingMeFault", ((BindingFault) bf).getName());
    } catch (ToolException e) {
        fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
    }
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) BindingInput(javax.wsdl.BindingInput) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) BindingOperation(javax.wsdl.BindingOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) Test(org.junit.Test)

Example 4 with SOAP12Operation

use of javax.wsdl.extensions.soap12.SOAP12Operation in project teiid by teiid.

the class WSDLMetadataProcessor method buildSoapOperation.

private void buildSoapOperation(MetadataFactory mf, BindingOperation bindingOperation) {
    Operation operation = bindingOperation.getOperation();
    // add input
    String inputXML = null;
    Input input = operation.getInput();
    if (input != null) {
        Message message = input.getMessage();
        if (message != null) {
            inputXML = message.getQName().getLocalPart();
        }
    }
    // add output
    String outXML = null;
    Output output = operation.getOutput();
    if (output != null) {
        Message message = output.getMessage();
        if (message != null) {
            outXML = message.getQName().getLocalPart();
        }
    }
    // $NON-NLS-1$
    ExtensibilityElement operationExtension = getExtensibilityElement(bindingOperation.getExtensibilityElements(), "operation");
    if (!(operationExtension instanceof SOAPOperation) && !(operationExtension instanceof SOAP12Operation)) {
        return;
    }
    if (operationExtension instanceof SOAPOperation) {
        // soap:operation
        SOAPOperation soapOperation = (SOAPOperation) operationExtension;
        String style = soapOperation.getStyle();
        if (style.equalsIgnoreCase("rpc")) {
            // $NON-NLS-1$
            LogManager.logInfo(LogConstants.CTX_CONNECTOR, WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15004, operation.getName()));
            return;
        }
    } else if (operationExtension instanceof SOAP12Operation) {
        // soap:operation
        SOAP12Operation soapOperation = (SOAP12Operation) operationExtension;
        String style = soapOperation.getStyle();
        if (style.equalsIgnoreCase("rpc")) {
            // $NON-NLS-1$
            LogManager.logInfo(LogConstants.CTX_CONNECTOR, WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15004, operation.getName()));
            return;
        }
    }
    Procedure procedure = mf.addProcedure(operation.getName());
    procedure.setVirtual(false);
    procedure.setNameInSource(operation.getName());
    mf.addProcedureParameter(inputXML, TypeFacility.RUNTIME_NAMES.XML, Type.In, procedure);
    // $NON-NLS-1$
    ProcedureParameter param = mf.addProcedureParameter("stream", TypeFacility.RUNTIME_NAMES.BOOLEAN, Type.In, procedure);
    // $NON-NLS-1$
    param.setAnnotation("If the result should be streamed.");
    param.setNullType(NullType.Nullable);
    // $NON-NLS-1$
    param.setDefaultValue("false");
    mf.addProcedureParameter(outXML, TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, procedure);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Input(javax.wsdl.Input) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) Message(javax.wsdl.Message) Output(javax.wsdl.Output) Procedure(org.teiid.metadata.Procedure) Operation(javax.wsdl.Operation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOperation(javax.wsdl.BindingOperation) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 5 with SOAP12Operation

use of javax.wsdl.extensions.soap12.SOAP12Operation in project tdi-studio-se by Talend.

the class ComponentBuilder method buildOperations.

private List buildOperations(Binding binding) {
    List operationInfos = new ArrayList();
    List operations = binding.getBindingOperations();
    if (operations != null && !operations.isEmpty()) {
        Vector soapBindingElems = findExtensibilityElement(binding.getExtensibilityElements(), "binding");
        // default
        String style = "document";
        ExtensibilityElement soapBindingElem = (ExtensibilityElement) soapBindingElems.elementAt(0);
        if (soapBindingElem != null && soapBindingElem instanceof SOAPBinding) {
            SOAPBinding soapBinding = (SOAPBinding) soapBindingElem;
            style = soapBinding.getStyle();
        } else if (soapBindingElem != null && soapBindingElem instanceof SOAP12Binding) {
            SOAP12Binding soapBinding = (SOAP12Binding) soapBindingElem;
            style = soapBinding.getStyle();
        }
        Iterator opIter = operations.iterator();
        while (opIter.hasNext()) {
            alldExtendtion.clear();
            BindingOperation oper = (BindingOperation) opIter.next();
            Vector operElems = findExtensibilityElement(oper.getExtensibilityElements(), "operation");
            ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
            if (operElem != null && operElem instanceof SOAPOperation) {
                OperationInfo operationInfo = new OperationInfo(style);
                buildOperation(operationInfo, oper);
                operationInfos.add(operationInfo);
            } else if (operElem != null && operElem instanceof SOAP12Operation) {
                OperationInfo operationInfo = new OperationInfo(style);
                buildOperation(operationInfo, oper);
                operationInfos.add(operationInfo);
            }
        }
    }
    return operationInfos;
}
Also used : OperationInfo(org.talend.designer.webservice.ws.wsdlinfo.OperationInfo) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Aggregations

BindingOperation (javax.wsdl.BindingOperation)6 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)6 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)4 Binding (javax.wsdl.Binding)3 BindingInput (javax.wsdl.BindingInput)3 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)3 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)3 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Vector (java.util.Vector)2 Input (javax.wsdl.Input)2 Message (javax.wsdl.Message)2 Operation (javax.wsdl.Operation)2 Output (javax.wsdl.Output)2 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)2 QName (javax.xml.namespace.QName)2 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)2