簡體   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