Reputation: 95
I've been trying for a few days to use spring boot with Apache CXF to generate a SOAP 1.2 endpoint, however even though the WSDL doesn't use a SOAP 1.1 namespace, spring keeps generating a SOAP 1.1 and SOAP 1.2 endpoint at the same location!
My wsdl definition only has an endpoint for SOAP 1.2
<wsdl:service name="MyService">
<wsdl:port name="IMyServicePort" binding="tns:IMyServiceBinding">
<soap12:address location="http://localhost:8080/MyService/services/IMyServicePort"/>
</wsdl:port>
</wsdl:service>
The web service beans file contains the following;
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">
<!-- Import the necessary CXF configuration files -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12" />
</property>
<property name="messageFactory">
<null />
</property>
</bean>
<jaxws:endpoint id="service" implementor="#ImyServiceImpl"
address="/myService/v1" wsdlLocation="wsdl/MyService.wsdl">
<jaxws:binding>
<soap:soapBinding mtomEnabled="true" version="1.2"/>
</jaxws:binding>
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
<entry key="jaxb-validation-event-handler">
<bean
class="myservice.OutSoapFaultInterceptor"></bean>
</entry>
</jaxws:properties>
</jaxws:endpoint>
</beans>
However, when I browse to the wsdl, I see both SOAP 1.1 and SOAP 1.2 endpoints
<wsdl:service name="MyService">
<wsdl:port binding="tns:IMyServiceBinding" name="IMyServicePort">
<soap12:address location="http://localhost:8080/services/services/myservice/v1"/>
</wsdl:port>
</wsdl:service>
<wsdl:service name="IMyServiceService">
<wsdl:port binding="tns:IMyServiceSoapBinding" name="IMyServicePort">
<soap:address location="http://localhost:8080/services/services/myservice/v1"/>
</wsdl:port>
</wsdl:service>
Annoyingly, there are both defined to be the same endpoint location, so I can't access the SOAP 1.2 endpoint, all requests are rejected with "A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint."
I can get around this by defining the endpoint in Java (although I cannot figure out how to replicate the jaxb-validation-event-handler in Java code!), but I'd rather use XML configuration.
Does anyone have any suggestions to either only generate a SOAP 1.2 endpoint, or know how separate out the endpoint locations so I can send the request to the SOAP 1.2 endpoint?
Upvotes: 2
Views: 2703
Reputation: 95
Well, I've no idea why a SOAP 1.1 interface was being generated by the WSDL...but, to solve my issue I just removed the wsdlLocation from the jaxws:endpoint definition, so;
<jaxws:endpoint id="service" implementor="#ImyServiceImpl"
address="/myService/v1" wsdlLocation="wsdl/MyService.wsdl">
became;
<jaxws:endpoint id="service" implementor="#ImyServiceImpl"
address="/myService/v1">
If I browse to /myService/v1, there is only a SOAP 1.2 definition there now.
Upvotes: 1