繁体   English   中英

具有CXF的Java Spring Boot生成SOAP 1.2端点

[英]Java Spring Boot with CXF generating SOAP 1.2 endpoint

我已经尝试了几天,以将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.2消息发送到仅SOAP 1.1端点时无效。”

我可以通过在Java中定义端点来解决此问题(尽管我无法弄清楚如何在Java代码中复制jaxb-validation-event-handler!),但我宁愿使用XML配置。

是否有人建议仅生成一个SOAP 1.2端点,或者知道如何将端点位置分开,以便我可以将请求发送到SOAP 1.2端点?

嗯,我不知道为什么WSDL会生成SOAP 1.1接口...但是,为了解决我的问题,我只是从jaxws:endpoint定义中删除了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,则现在只有SOAP 1.2定义。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM