Search in sources :

Example 1 with Soap12Body

use of com.helger.phase4.soap12.Soap12Body in project eclipselink by eclipse-ee4j.

the class WSDLGenerator method createMethodDefinition.

private void createMethodDefinition(WSDLFactory factory, ExtensionRegistry registry, Definition def, Operation operation, boolean useSOAP12) throws WSDLException {
    Message requestMessage = def.createMessage();
    requestMessage.setUndefined(false);
    requestMessage.setQName(new QName(serviceNameSpace, operation.getName() + REQUEST_SUFFIX));
    Part requestPart = def.createPart();
    requestPart.setName(operation.getName() + REQUEST_SUFFIX);
    requestPart.setElementName(new QName(serviceNameSpace, operation.getName()));
    requestMessage.addPart(requestPart);
    def.addMessage(requestMessage);
    Message responseMessage = null;
    if (operation.hasResponse()) {
        responseMessage = def.createMessage();
        responseMessage.setUndefined(false);
        responseMessage.setQName(new QName(serviceNameSpace, operation.getName() + RESPONSE_SUFFIX));
        Part responsePart = def.createPart();
        responsePart.setName(operation.getName() + RESPONSE_SUFFIX);
        responsePart.setElementName(new QName(serviceNameSpace, operation.getName() + RESPONSE_SUFFIX));
        responseMessage.addPart(responsePart);
        def.addMessage(responseMessage);
    }
    PortType portType = def.getPortType(new QName(serviceNameSpace, serviceName + PORT_SUFFIX));
    javax.wsdl.Operation op = def.createOperation();
    op.setUndefined(false);
    op.setName(operation.getName());
    Input input = def.createInput();
    input.setMessage(requestMessage);
    op.setInput(input);
    if (operation.hasResponse()) {
        Output output = def.createOutput();
        output.setMessage(responseMessage);
        op.setOutput(output);
    }
    portType.addOperation(op);
    Binding binding = def.getBinding(new QName(serviceNameSpace, serviceName + BINDING_SUFFIX));
    BindingOperation bop = def.createBindingOperation();
    bop.setName(operation.getName());
    ExtensibilityElement so = null;
    if (useSOAP12) {
        so = registry.createExtension(BindingOperation.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_OPERATION));
        ((SOAP12Operation) so).setSoapActionURI(serviceNameSpace + ":" + op.getName());
    } else {
        so = registry.createExtension(BindingOperation.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_OPERATION));
        ((SOAPOperation) so).setSoapActionURI(serviceNameSpace + ":" + op.getName());
    }
    bop.addExtensibilityElement(so);
    BindingInput bi = def.createBindingInput();
    ExtensibilityElement soapInputBody = null;
    if (useSOAP12) {
        soapInputBody = registry.createExtension(BindingInput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
        ((SOAP12Body) soapInputBody).setUse(SOAP_USE);
    } else {
        soapInputBody = registry.createExtension(BindingInput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
        ((SOAPBody) soapInputBody).setUse(SOAP_USE);
    }
    bi.addExtensibilityElement(soapInputBody);
    bop.setBindingInput(bi);
    if (operation.hasResponse()) {
        BindingOutput bo = def.createBindingOutput();
        ExtensibilityElement soapOutputBody = null;
        if (useSOAP12) {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAP12Body) soapOutputBody).setUse(SOAP_USE);
        } else {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAPBody) soapOutputBody).setUse(SOAP_USE);
        }
        bo.addExtensibilityElement(soapOutputBody);
        bop.setBindingOutput(bo);
    }
    if (!(operation instanceof QueryOperation)) {
        // non-QueryOperations don't have Responses, but the fault requirements
        // mean we have to create 'dummy' WSDL outputs
        BindingOutput bo = def.createBindingOutput();
        ExtensibilityElement soapOutputBody = null;
        if (useSOAP12) {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAP12Body) soapOutputBody).setUse(SOAP_USE);
        } else {
            soapOutputBody = registry.createExtension(BindingOutput.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_BODY));
            ((SOAPBody) soapOutputBody).setUse(SOAP_USE);
        }
        bo.addExtensibilityElement(soapOutputBody);
        bop.setBindingOutput(bo);
        // add WSDL fault to binding operations
        BindingFault bindingFault = def.createBindingFault();
        String exceptionName = FAULT_SUFFIX + EXCEPTION_SUFFIX;
        bindingFault.setName(exceptionName);
        ExtensibilityElement soapFaultBody = null;
        if (useSOAP12) {
            soapFaultBody = registry.createExtension(BindingFault.class, new QName(SOAP_12_NAMESPACE_URI, TAG_SOAP_FAULT));
            ((SOAP12Fault) soapFaultBody).setUse(SOAP_USE);
            ((SOAP12Fault) soapFaultBody).setName(exceptionName);
        } else {
            soapFaultBody = registry.createExtension(BindingFault.class, new QName(SOAP_11_NAMESPACE_URI, TAG_SOAP_FAULT));
            ((SOAPFault) soapFaultBody).setUse(SOAP_USE);
            ((SOAPFault) soapFaultBody).setName(exceptionName);
        }
        bindingFault.addExtensibilityElement(soapFaultBody);
        bop.addBindingFault(bindingFault);
        Message emptyResponseMessage = def.getMessage(new QName(serviceNameSpace, EMPTY_RESPONSE));
        Output output = def.createOutput();
        output.setName(operation.getName() + EMPTY_RESPONSE);
        output.setMessage(emptyResponseMessage);
        op.setOutput(output);
        Message faultMessage = def.getMessage(new QName(serviceNameSpace, FAULT_SUFFIX + TYPE_SUFFIX));
        Fault fault = def.createFault();
        fault.setMessage(faultMessage);
        fault.setName(exceptionName);
        op.addFault(fault);
    }
    binding.addBindingOperation(bop);
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingOutput(javax.wsdl.BindingOutput) Message(javax.wsdl.Message) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) SOAP12Fault(javax.wsdl.extensions.soap12.SOAP12Fault) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) SOAPFault(javax.wsdl.extensions.soap.SOAPFault) SOAP12Fault(javax.wsdl.extensions.soap12.SOAP12Fault) BindingInput(javax.wsdl.BindingInput) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) BindingOperation(javax.wsdl.BindingOperation) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) Part(javax.wsdl.Part) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) SOAPFault(javax.wsdl.extensions.soap.SOAPFault) PortType(javax.wsdl.PortType) QueryOperation(org.eclipse.persistence.internal.xr.QueryOperation)

Example 2 with Soap12Body

use of com.helger.phase4.soap12.Soap12Body in project phase4 by phax.

the class AbstractAS4Message method getAsSoapDocument.

@Nonnull
public final Document getAsSoapDocument(@Nullable final Node aPayload) {
    // Convert to DOM Node
    final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(m_aMessaging);
    if (aEbms3Document == null)
        throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
    final Node aRealPayload = aPayload instanceof Document ? ((Document) aPayload).getDocumentElement() : aPayload;
    switch(m_eSoapVersion) {
        case SOAP_11:
            {
                // Creating SOAP 11 Envelope
                final Soap11Envelope aSoapEnv = new Soap11Envelope();
                aSoapEnv.setHeader(new Soap11Header());
                aSoapEnv.setBody(new Soap11Body());
                aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
                if (aRealPayload != null)
                    aSoapEnv.getBody().addAny(aRealPayload);
                return Ebms3WriterBuilder.soap11().getAsDocument(aSoapEnv);
            }
        case SOAP_12:
            {
                // Creating SOAP 12 Envelope
                final Soap12Envelope aSoapEnv = new Soap12Envelope();
                aSoapEnv.setHeader(new Soap12Header());
                aSoapEnv.setBody(new Soap12Body());
                aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
                if (aRealPayload != null)
                    aSoapEnv.getBody().addAny(aRealPayload);
                return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
            }
        default:
            throw new IllegalStateException("Unsupported SOAP version " + m_eSoapVersion);
    }
}
Also used : Soap11Envelope(com.helger.phase4.soap11.Soap11Envelope) Soap12Envelope(com.helger.phase4.soap12.Soap12Envelope) Soap11Header(com.helger.phase4.soap11.Soap11Header) Node(org.w3c.dom.Node) Soap12Header(com.helger.phase4.soap12.Soap12Header) Soap11Body(com.helger.phase4.soap11.Soap11Body) Soap12Body(com.helger.phase4.soap12.Soap12Body) Document(org.w3c.dom.Document) Nonnull(javax.annotation.Nonnull)

Example 3 with Soap12Body

use of com.helger.phase4.soap12.Soap12Body in project phase4 by phax.

the class Ebms3MessagingTest method _getMessagingAsSoapDocument.

@Nullable
private Document _getMessagingAsSoapDocument(@Nonnull final Ebms3Messaging aEbms3Messaging) {
    final Document aEbms3Document = Ebms3WriterBuilder.ebms3Messaging().getAsDocument(aEbms3Messaging);
    if (aEbms3Document == null)
        throw new IllegalStateException("Failed to write EBMS3 Messaging to XML");
    // Creating SOAP 12 Envelope
    final Soap12Envelope aSoapEnv = new Soap12Envelope();
    aSoapEnv.setHeader(new Soap12Header());
    aSoapEnv.setBody(new Soap12Body());
    aSoapEnv.getHeader().addAny(aEbms3Document.getDocumentElement());
    return Ebms3WriterBuilder.soap12().getAsDocument(aSoapEnv);
}
Also used : Soap12Envelope(com.helger.phase4.soap12.Soap12Envelope) Soap12Header(com.helger.phase4.soap12.Soap12Header) Soap12Body(com.helger.phase4.soap12.Soap12Body) Document(org.w3c.dom.Document) Nullable(javax.annotation.Nullable)

Example 4 with Soap12Body

use of com.helger.phase4.soap12.Soap12Body 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 5 with Soap12Body

use of com.helger.phase4.soap12.Soap12Body 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)

Aggregations

SOAP12Body (javax.wsdl.extensions.soap12.SOAP12Body)12 SOAPBody (javax.wsdl.extensions.soap.SOAPBody)8 BindingOperation (javax.wsdl.BindingOperation)6 Iterator (java.util.Iterator)5 QName (javax.xml.namespace.QName)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 BindingInput (javax.wsdl.BindingInput)4 Part (javax.wsdl.Part)4 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)4 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)4 Binding (javax.wsdl.Binding)3 BindingOutput (javax.wsdl.BindingOutput)3 Message (javax.wsdl.Message)3 MIMEMultipartRelated (javax.wsdl.extensions.mime.MIMEMultipartRelated)3 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)3 Soap12Body (com.helger.phase4.soap12.Soap12Body)2 Soap12Envelope (com.helger.phase4.soap12.Soap12Envelope)2 Soap12Header (com.helger.phase4.soap12.Soap12Header)2