Search in sources :

Example 11 with SOAPBody

use of javax.wsdl.extensions.soap.SOAPBody 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 12 with SOAPBody

use of javax.wsdl.extensions.soap.SOAPBody in project pentaho-kettle by pentaho.

the class WsdlUtils method getSOAPBindingUse.

/**
 * Get the SOAP Use type for the specified operation.
 *
 * @param binding
 *          A WSDL Binding instance.
 * @param operationName
 *          The name of the operation.
 * @return Either 'literal' or 'encoded'.
 * @throws RuntimeException
 *           If the use type cannot be determined.
 */
protected static String getSOAPBindingUse(Binding binding, String operationName) {
    BindingOperation bindingOperation = binding.getBindingOperation(operationName, null, null);
    if (bindingOperation == null) {
        throw new IllegalArgumentException("Can not find operation: " + operationName);
    }
    // first try getting the use setting from the input message
    BindingInput bindingInput = bindingOperation.getBindingInput();
    if (bindingInput != null) {
        ExtensibilityElement soapBodyElem = WsdlUtils.findExtensibilityElement(bindingInput, SOAP_BODY_ELEMENT_NAME);
        if (soapBodyElem != null) {
            if (soapBodyElem instanceof SOAP12BodyImpl) {
                return ((SOAP12BodyImpl) soapBodyElem).getUse();
            } else {
                return ((SOAPBody) soapBodyElem).getUse();
            }
        }
    }
    // if there was no input message try getting the use from the output message
    BindingOutput bindingOutput = bindingOperation.getBindingOutput();
    if (bindingOutput != null) {
        ExtensibilityElement soapBodyElem = WsdlUtils.findExtensibilityElement(bindingOutput, SOAP_BODY_ELEMENT_NAME);
        if (soapBodyElem != null) {
            if (soapBodyElem instanceof SOAP12BodyImpl) {
                return ((SOAP12BodyImpl) soapBodyElem).getUse();
            } else {
                return ((SOAPBody) soapBodyElem).getUse();
            }
        }
    }
    throw new RuntimeException("Unable to determine SOAP use for operation: " + operationName);
}
Also used : BindingOperation(javax.wsdl.BindingOperation) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) BindingOutput(javax.wsdl.BindingOutput) SOAP12BodyImpl(com.ibm.wsdl.extensions.soap12.SOAP12BodyImpl) BindingInput(javax.wsdl.BindingInput) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Aggregations

SOAPBody (javax.wsdl.extensions.soap.SOAPBody)12 BindingOperation (javax.wsdl.BindingOperation)7 BindingInput (javax.wsdl.BindingInput)6 QName (javax.xml.namespace.QName)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BindingOutput (javax.wsdl.BindingOutput)3 Operation (javax.wsdl.Operation)3 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)3 ValidationFailure (org.apache.openejb.config.ValidationFailure)3 Iterator (java.util.Iterator)2 Binding (javax.wsdl.Binding)2 Input (javax.wsdl.Input)2 Message (javax.wsdl.Message)2 Output (javax.wsdl.Output)2 Part (javax.wsdl.Part)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)2 OMElement (org.apache.axiom.om.OMElement)2