Search in sources :

Example 16 with BindingInput

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

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

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

the class WSDLToCorbaBinding method addBindingOperations.

private void addBindingOperations(Definition definition, PortType portType, Binding binding) throws Exception {
    List<Operation> ops = CastUtils.cast(portType.getOperations());
    for (Operation op : ops) {
        try {
            BindingOperation bindingOperation = definition.createBindingOperation();
            addCorbaOperationExtElement(bindingOperation, op);
            bindingOperation.setName(op.getName());
            if (op.getInput() != null) {
                BindingInput bindingInput = definition.createBindingInput();
                bindingInput.setName(op.getInput().getName());
                bindingOperation.setBindingInput(bindingInput);
            }
            if (op.getOutput() != null) {
                BindingOutput bindingOutput = definition.createBindingOutput();
                bindingOutput.setName(op.getOutput().getName());
                bindingOperation.setBindingOutput(bindingOutput);
            }
            // add Faults
            if (op.getFaults() != null && op.getFaults().size() > 0) {
                Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
                for (Fault fault : faults) {
                    BindingFault bindingFault = definition.createBindingFault();
                    bindingFault.setName(fault.getName());
                    bindingOperation.addBindingFault(bindingFault);
                }
            }
            bindingOperation.setOperation(op);
            binding.addBindingOperation(bindingOperation);
        } catch (Exception ex) {
            LOG.warning("Operation " + op.getName() + " not mapped to CORBA binding.");
        }
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation) BindingOutput(javax.wsdl.BindingOutput) BindingFault(javax.wsdl.BindingFault) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingInput(javax.wsdl.BindingInput) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 19 with BindingInput

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

the class OperationVisitor method generateInputMessage.

public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
    Message msg = definition.createMessage();
    QName msgName;
    if (!mapper.isDefaultMapping()) {
        // mangle the message name
        // REVISIT, do we put in the entire scope for mangling
        msgName = new QName(definition.getTargetNamespace(), getScope().tail() + "." + operation.getName());
    } else {
        msgName = new QName(definition.getTargetNamespace(), operation.getName());
    }
    msg.setQName(msgName);
    msg.setUndefined(false);
    String inputName = operation.getName() + REQUEST_SUFFIX;
    Input input = definition.createInput();
    input.setName(inputName);
    input.setMessage(msg);
    BindingInput bindingInput = definition.createBindingInput();
    bindingInput.setName(inputName);
    bindingOperation.setBindingInput(bindingInput);
    operation.setInput(input);
    definition.addMessage(msg);
    return msg;
}
Also used : BindingInput(javax.wsdl.BindingInput) Input(javax.wsdl.Input) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) BindingInput(javax.wsdl.BindingInput)

Example 20 with BindingInput

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

the class PartialWSDLProcessor method getBindingInput.

private static BindingInput getBindingInput(Input input, Definition wsdlDefinition, ExtensionRegistry extReg) throws Exception {
    BindingInput bi = wsdlDefinition.createBindingInput();
    bi.setName(input.getName());
    bi.addExtensibilityElement(getSoapBody(BindingInput.class, extReg));
    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