Reputation: 2776
I have a Spring Boot based project using CXF to build a SOAP Web Service.
Sending SOAP 1.1 messages (using SOAPUI) works fine, but when I try to send SOAP 1.2 messaged (using the same WSDL of course) I get the message "A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint"
.
The message is self explaining, but I can't understand why my endpoint doesn't accept 1.2 messages.
My WSDL contains the correct bindings and namespaces for soap12.
In my spring @Configuration class I added this to the CXF endpoint bean:
endpoint.setBindingConfig(new BindingConfiguration()
{
@Override
public String getBindingId()
{
return SOAPBinding.SOAP12HTTP_MTOM_BINDING;
}
});
That didn't help.
As I became more desperate, I tried both the @BindingType
and @SOAPBinding
annotations which of course didn't work, then I tried SaajSoapMessageFactory
with SoapVersion.SOAP_12
. Didn't work. I tried <extension>true</extension><protocol>Xsoap1.2</protocol>
in my jaxws-maven-plugin
. Failed.
The endpoint is clearly not configured for receiving SOAP 1.2 messages. How do I achieve this?
Upvotes: 4
Views: 6510
Reputation: 2776
I figured it out. I needed to set the binding url when implementing the endpoint. For some unapparent reason setting it afterwards did not work.
EndpointImpl endpoint = new EndpointImpl(springBus(), statusService(), SOAPBinding.SOAP12HTTP_BINDING);
Upvotes: 5
Reputation: 543
It looks like your request you are sending is hitting a SOAP 1.1 endpoint instead of a SOAP 1.2.
If your WSDL was built using top down approach make sure the SOAP Binding for SOAP 1.2 exists in the wsdl. Also the Port (wsdl:port) for SOAP 1.2 must appear under wsdl:service in the wsdl.
If it was built using bottom up approach make sure this annotation @BindingType(value = SOAPBinding.SOAP12HTTP_MTOM_BINDING) is on your SIB when mtom is enabled otherwise use @BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING).
Then on client wsdl generation using your maven plugin make sure to use <extension>true</extension>
.
After the above, for example if you are using wsdl with 2 ports in the wsdl:service section as below:
<wsdl:service name="TestService">
<wsdl:port name="TestPortSoap11" binding="tns:TestPort12Binding">
<soap:address location="http://127.0.0.1:8081/testSoap11Endpoint"/>
</wsdl:port>
<wsdl:port name="TestPortSoap12" binding="tns:TestPort12Binding">
<soap12:address location="http://127.0.0.1:8081/testSoap12Endpoint"/>
</wsdl:port>
</wsdl:service>
For you to use soap 1.2 endpoint make sure you get the instance of the service by calling something like:
TestPortType testService = new TestService().getTestPortSoap12();
Please note the text in bold "new TestService().getTestPortSoap12()" is matching the name of the SOAP 1.2 port name in the wsdl.
OR in your configuration of the web service client make sure the endpoint address you are using is pointing to a SOAP 1.2 port and in our case, for example, it's http://127.0.0.1:8081/testSoap12Endpoint not http://127.0.0.1:8081/testSoap11Endpoint.
If these steps fail, kindly share the wsdl snippet (showing wsdl:service section) and your @Configuration web service spring configs.
Upvotes: 0