几天来,我一直在尝试使用spring boot和Apache CXF来生成SOAP 1.2端点,然而,即使WSDL没有使用SOAP 1.1命名空间,spring仍然在同一位置生成SOAP 1.1和SOAP 1.2端点!
我的wsdl定义只有一个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>
web服务bean文件包含以下内容;
<?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>
但是,当我浏览到wsdl时,我同时看到了SOAP 1.1和SOAP 1.2端点
<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>
令人恼火的是,两者都被定义为相同的端点位置,因此我不能访问SOAP 1.2端点,所有请求都会被拒绝,并显示"A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint“。
我可以通过在Java中定义端点来解决这个问题(尽管我不知道如何在Java代码中复制jaxb-validation-event-handler!),但我更喜欢使用XML配置。
有没有人有什么建议或者只生成SOAP 1.2端点,或者知道如何分离端点位置以便我可以将请求发送到SOAP 1.2端点?
发布于 2018-06-14 04:35:38
好吧,我不知道为什么WSDL...but会生成SOAP1.1接口,为了解决我的问题,我只是从jaxws:端点定义中删除了wsdlLocation,所以;
<jaxws:endpoint id="service" implementor="#ImyServiceImpl"
address="/myService/v1" wsdlLocation="wsdl/MyService.wsdl">
变成了;
<jaxws:endpoint id="service" implementor="#ImyServiceImpl"
address="/myService/v1">
如果我浏览到/myService/v1,这里现在只有一个SOAP1.2定义。
https://stackoverflow.com/questions/50844946
复制相似问题