【发布时间】:2018-06-13 19:34:48
【问题描述】:
几天来,我一直在尝试将 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 端点,所有请求都被拒绝,并显示“发送到仅 SOAP 1.1 的端点时,SOAP 1.2 消息无效”。
我可以通过在 Java 中定义端点来解决这个问题(尽管我不知道如何在 Java 代码中复制 jaxb-validation-event-handler!),但我宁愿使用 XML 配置。
是否有人建议只生成一个 SOAP 1.2 端点,或者知道如何分离端点位置以便我可以将请求发送到 SOAP 1.2 端点?
【问题讨论】:
标签: java spring web-services spring-boot soap