CXF How to set SoapVersion on CXF port without Spring

后端 未结 5 1716
遇见更好的自我
遇见更好的自我 2020-12-30 10:14

I am currently working on a Web Service client using CXF without Spring configuration files.

It works pretty well but I cannot figure out how to set the binding Soap

相关标签:
5条回答
  • 2020-12-30 10:17

    Easiest is probably to just stick an annotation on the interface of:

    @BindingType(SOAPBinding.SOAP12HTTP_BINDING)
    
    0 讨论(0)
  • 2020-12-30 10:22

    As suggested by Donal Fellows I answer to my own question ;)

    Actually the issue was linked to the Soap version the server can handle. On the client side I do not need to specify that I want to use Soap 1.2, it seems it's sufficient to have the PortType in the WSDL file configured to Soap 1.2. But on the server side I need to explicitly tell which Soap version I want. On the server side I still use the "Spring-mode" for CXF configuration thus I just added the following in the XML configuration file:

    <jaxws:binding>
        <soap:soapBinding version="1.2"/>
    </jaxws:binding>
    

    That's all folks! Thanks for your time and help!

    EDIT --------------------------------

    Actually this solution does not work now that we contact a server we do not manage.... We are still stuck with our problem here....

    0 讨论(0)
  • Old thread. I thought I'd post a solution that worked for me. In the cxf-beans.xml file, I changed the endpointName="tns:MR_ServerSoap12" from endpointName="tns:MR_ServerSoap". Note that the endpoint name will have its own name in your wsdl. Use that name.

    0 讨论(0)
  • 2020-12-30 10:37

    Ok I answer again to my own question to share the solution. With the help of the guys from the CXF mailing list I found a solution that works for me. There is actually 2 ways to solve the problem. Here is the explanation:

    The problem came from the way I was building my CXF Service.

    The first solution is to specify the WSDL location at Service creation time:

    // Create the service
    Service service = Service.create(urlToWsdl, serviceQName);
    // Access the port
    return service.getPort(serviceQName, portTypeClass);
    

    This solved the problem but I didn't want to have that link to the WSDL, so here is the second solution that gets rid of this link:

    // Create the service
    Service service = Service.create(serviceQName);
    // Add a Port to the service and specify the SOAP 1.2 binding
    service.addPort(serviceQName, javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING, wsUrl);
    // Access the port
    return service.getPort(serviceQName, portTypeClass);
    

    In my project we decided to choose the second solution.

    Hope this helps!

    0 讨论(0)
  • 2020-12-30 10:39

    if you are using cxf client , you can use following way. Also it can bind more than one wsdl.

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(WebServiceClass);
            BindingConfiguration config = new BindingConfiguration() {
    
        @Override
        public String getBindingId() {
                // TODO Auto-generated method stub
                return "http://www.w3.org/2003/05/soap/bindings/HTTP/";//SOAPVersion.SOAP_12.httpBindingId
        }
        };
        factory.setBindingConfig(config);
    
    0 讨论(0)
提交回复
热议问题