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 SoapVersion using the Java Api.
Using a Spring file this is done as the following:
<jaxws:binding>
<soap:soapBinding version="1.2"/>
</jaxws:binding>
Do you guys know how to do this in the Java code (on the Port, on the SOAPBinding...)?
Thanks in advance for your help!
EDIT----------------------
I'm still stuck with this problem...
I tried to add the SOAPBinding annotation on the interface as suggested in one of the response below but it didn't work...
I'm still searching for a way to manually configure my PortType / Binding / Bus to use Soap 1.2...
Any ideas?
EDIT----------------------
Problem solved! Actually I answered my own question: see below...
Thanks!
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!
Easiest is probably to just stick an annotation on the interface of:
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
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);
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....
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.