CXF How to set SoapVersion on CXF port without Spring

后端 未结 5 1722
遇见更好的自我
遇见更好的自我 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: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!

提交回复
热议问题