Search in sources :

Example 6 with SoapOperation

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation in project cxf by apache.

the class WSDLToSoapProcessorTest method testDocLitWithFault.

@Test
public void testDocLitWithFault() throws Exception {
    String[] args = new String[] { "-i", "Greeter", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world_doc_lit.wsdl") };
    WSDLToSoap.main(args);
    File outputFile = new File(output, "hello_world_doc_lit-soapbinding.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_Binding"));
        if (binding == null) {
            fail("Element wsdl:binding Greeter_Binding Missed!");
        }
        boolean found = false;
        for (Object obj : binding.getExtensibilityElements()) {
            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
            if (soapBinding != null && soapBinding.getStyle().equalsIgnoreCase("document")) {
                found = true;
                break;
            }
        }
        if (!found) {
            fail("Element soap:binding Missed!");
        }
        BindingOperation bo = binding.getBindingOperation("pingMe", null, null);
        if (bo == null) {
            fail("Element <wsdl:operation name=\"pingMe\"> Missed!");
        }
        found = false;
        for (Object obj : bo.getExtensibilityElements()) {
            SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
            if (soapOperation != null && soapOperation.getStyle().equalsIgnoreCase("document")) {
                found = true;
                break;
            }
        }
        if (!found) {
            fail("Element soap:operation Missed!");
        }
        BindingFault fault = bo.getBindingFault("pingMeFault");
        if (fault == null) {
            fail("Element <wsdl:fault name=\"pingMeFault\"> Missed!");
        }
        found = false;
        for (Object obj : fault.getExtensibilityElements()) {
            if (SOAPBindingUtil.isSOAPFault(obj)) {
                found = true;
                break;
            }
        }
        if (!found) {
            fail("Element soap:fault Missed!");
        }
        List<SoapFault> faults = SOAPBindingUtil.getBindingOperationSoapFaults(bo);
        assertEquals(1, faults.size());
        assertEquals("pingMeFault", faults.get(0).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) SoapFault(org.apache.cxf.binding.soap.wsdl.extensions.SoapFault) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) BindingOperation(javax.wsdl.BindingOperation) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) Test(org.junit.Test)

Example 7 with SoapOperation

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation in project cxf by apache.

the class WSDLToSoapProcessorTest method testWithoutBinding.

@Test
public void testWithoutBinding() throws Exception {
    String[] args = new String[] { "-i", "Greeter", "-b", "Greeter_SOAPBinding", "-d", output.getCanonicalPath(), "-o", "hello_world_soap_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_nobinding.wsdl") };
    WSDLToSoap.main(args);
    File outputFile = new File(output, "hello_world_soap_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_SOAPBinding"));
        if (binding == null) {
            fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
        }
        for (Object obj : binding.getExtensibilityElements()) {
            assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
            assertTrue(obj instanceof SOAPBinding);
            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
            assertNotNull(soapBinding);
            assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
            assertTrue(WSDLConstants.NS_SOAP11_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 SOAPOperation);
            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 SOAPBody);
            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) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) QName(javax.xml.namespace.QName) SoapBody(org.apache.cxf.binding.soap.wsdl.extensions.SoapBody) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) BindingInput(javax.wsdl.BindingInput) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) BindingOperation(javax.wsdl.BindingOperation) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) Test(org.junit.Test)

Example 8 with SoapOperation

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation in project cxf by apache.

the class WSDLToSoapProcessorTest method testRpcLitWithoutFault.

@Test
public void testRpcLitWithoutFault() throws Exception {
    String[] args = new String[] { "-i", "GreeterRPCLit", "-n", "http://apache.org/hello_world_rpclit_test", "-b", "Greeter_SOAPBinding_NewBinding", "-style", "rpc", "-use", "literal", "-d", output.getCanonicalPath(), "-o", "hello_world_rpc_lit_newbinding.wsdl", getLocation("/misctools_wsdl/hello_world_rpc_lit.wsdl") };
    WSDLToSoap.main(args);
    File outputFile = new File(output, "hello_world_rpc_lit_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_SOAPBinding_NewBinding"));
        if (binding == null) {
            fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
        }
        boolean found = false;
        for (Object obj : binding.getExtensibilityElements()) {
            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
            if (soapBinding != null && soapBinding.getStyle().equalsIgnoreCase("rpc")) {
                found = true;
                break;
            }
        }
        if (!found) {
            fail("Element soap:binding style=rpc Missed!");
        }
        BindingOperation bo = binding.getBindingOperation("sendReceiveData", null, null);
        if (bo == null) {
            fail("Element <wsdl:operation name=\"sendReceiveData\"> Missed!");
        }
        found = false;
        for (Object obj : bo.getExtensibilityElements()) {
            SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
            if (soapOperation != null && soapOperation.getStyle().equalsIgnoreCase("rpc")) {
                found = true;
                break;
            }
        }
        if (!found) {
            fail("Element soap:operation style=rpc Missed!");
        }
        BindingInput bi = bo.getBindingInput();
        found = false;
        for (Object obj : bi.getExtensibilityElements()) {
            SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
            if (soapBody != null && soapBody.getUse().equalsIgnoreCase("literal")) {
                found = true;
                break;
            }
        }
        if (!found) {
            fail("Element soap:body use=literal Missed!");
        }
    } 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) 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) BindingOperation(javax.wsdl.BindingOperation) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File) Test(org.junit.Test)

Example 9 with SoapOperation

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation in project cxf by apache.

the class SOAPBindingUtil method isMixedStyle.

public static boolean isMixedStyle(Binding binding) {
    String bindingStyle = "";
    String previousOpStyle = "";
    String style = "";
    for (Object obj : binding.getExtensibilityElements()) {
        if (isSOAPBinding(obj)) {
            SoapBinding soapBinding = getSoapBinding(obj);
            bindingStyle = soapBinding.getStyle();
            if (bindingStyle == null) {
                bindingStyle = "";
            }
        }
    }
    for (Object bobj : binding.getBindingOperations()) {
        BindingOperation bop = (BindingOperation) bobj;
        for (Object obj : bop.getExtensibilityElements()) {
            if (isSOAPOperation(obj)) {
                SoapOperation soapOperation = getSoapOperation(obj);
                style = soapOperation.getStyle();
                if (style == null) {
                    style = "";
                }
                if ("".equals(bindingStyle) && "".equals(previousOpStyle) || "".equals(bindingStyle) && previousOpStyle.equalsIgnoreCase(style)) {
                    previousOpStyle = style;
                } else if (!"".equals(bindingStyle) && "".equals(previousOpStyle) && bindingStyle.equalsIgnoreCase(style) || bindingStyle.equalsIgnoreCase(previousOpStyle) && bindingStyle.equalsIgnoreCase(style)) {
                    previousOpStyle = style;
                } else if (!"".equals(bindingStyle) && "".equals(style) && "".equals(previousOpStyle)) {
                    continue;
                } else {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)

Example 10 with SoapOperation

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation in project cxf by apache.

the class SoapBindingFactory method initializeBindingOperation.

private void initializeBindingOperation(SoapBindingInfo bi, BindingOperationInfo boi) {
    SoapOperationInfo soi = new SoapOperationInfo();
    SoapOperation soapOp = SOAPBindingUtil.getSoapOperation(boi.getExtensors(ExtensibilityElement.class));
    if (soapOp != null) {
        String action = soapOp.getSoapActionURI();
        if (action == null) {
            action = "";
        }
        soi.setAction(action);
        soi.setStyle(soapOp.getStyle());
    }
    boi.addExtensor(soi);
    if (boi.getInput() != null) {
        initializeMessage(bi, boi, boi.getInput());
    }
    if (boi.getOutput() != null) {
        initializeMessage(bi, boi, boi.getOutput());
    }
}
Also used : SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Aggregations

SoapOperation (org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation)10 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)7 BindingOperation (javax.wsdl.BindingOperation)6 ToolException (org.apache.cxf.tools.common.ToolException)6 File (java.io.File)5 Binding (javax.wsdl.Binding)5 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)5 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)5 QName (javax.xml.namespace.QName)5 SoapBody (org.apache.cxf.binding.soap.wsdl.extensions.SoapBody)5 Test (org.junit.Test)5 BindingInput (javax.wsdl.BindingInput)4 BindingFault (javax.wsdl.BindingFault)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)2 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)2 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)2 SoapFault (org.apache.cxf.binding.soap.wsdl.extensions.SoapFault)2 HashMap (java.util.HashMap)1 WSDLException (javax.wsdl.WSDLException)1