Search in sources :

Example 11 with SoapBinding

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding 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 12 with SoapBinding

use of org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding 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 13 with SoapBinding

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

the class SOAPBindingUtil method createSoapBinding.

public static SoapBinding createSoapBinding(ExtensionRegistry extReg, boolean isSOAP12) throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(Binding.class, new QName(WSDLConstants.NS_SOAP12, "binding"));
        ((SOAP12Binding) extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    } else {
        extElement = extReg.createExtension(Binding.class, new QName(WSDLConstants.NS_SOAP11, "binding"));
        ((SOAPBinding) extElement).setTransportURI(WSDLConstants.NS_SOAP_HTTP_TRANSPORT);
    }
    return getSoapBinding(extElement);
}
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) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) QName(javax.xml.namespace.QName) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Aggregations

SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)13 ToolException (org.apache.cxf.tools.common.ToolException)8 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)7 QName (javax.xml.namespace.QName)7 SoapOperation (org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation)7 Binding (javax.wsdl.Binding)6 BindingOperation (javax.wsdl.BindingOperation)6 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)6 File (java.io.File)5 SoapBody (org.apache.cxf.binding.soap.wsdl.extensions.SoapBody)5 Test (org.junit.Test)5 BindingInput (javax.wsdl.BindingInput)4 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)4 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)3 Message (org.apache.cxf.common.i18n.Message)3 BindingFault (javax.wsdl.BindingFault)2 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)2 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)2 SoapFault (org.apache.cxf.binding.soap.wsdl.extensions.SoapFault)2 WSDLManager (org.apache.cxf.wsdl.WSDLManager)2