Spring Integration ws出站网关引发webservicetransportexception not-



我们使用ws出站网关以以下方式调用Web服务。

<ws:outbound-gateway uri="http://localhost:8080/test" message-factory="messageFactory" message-sender="messageSender" ignore-empty-responses="false" requires-reply="true" />
<bean name="messageSender" class="org.springframework.ws.transport.http.HttpComponentsMessageSender">
</bean>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_11"/>
</property>
</bean>

如果请求xml采用以下方式,那么它完全可以正常工作。

<?xml version="1.0" encoding="UTF-8"?>
<m:processRequest xmlns:m="http://ws.test.com">
<request>
<dealerId>999852</dealerId>
.......
.......
</request>
</m:processRequest>

如果我添加SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"并且SOAP-ENV:Body在请求xml中,它抛出如下错误:

org.springframework.ws.client.WebServiceTransportException:找不到[404]

堆栈跟踪:

org.springframework.ws.client.WebServiceTransportException: Not Found [404]
at org.springframework.ws.client.core.WebServiceTemplate.handleError(WebServiceTemplate.java:590)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:514)
at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:465)
at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:420)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:366)
at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceiveToResult(WebServiceTemplate.java:351)
at com.railinc.notifserv.services.findusrail.impl.FindUsRailContactServiceImpl.getFindUsRailContacts(FindUsRailContactServiceImpl.java:31)
at com.railinc.notifserv.services.findusrail.impl.FindUsRailContactServiceImplTest.testGetFindUsRailContacts(FindUsRailContactServiceImplTest.java:9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

失败错误xml:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<m:processRequest xmlns:m="http://ws.test.com">
<request>
<dealerId>999852</dealerId>
.......
.......
</request>
</m:processRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

有没有一种方法可以使用ws出站网关将请求xml和soap信封一起发送?

我在您提出的问题中给了您一个答案:https://github.com/spring-projects/spring-integration-samples/issues/231.所以,让我在这里重复一遍!

您的问题是,您不必将一个完整的SOAP信封发送到WS-Outbound网关。实际上,您只需要为SOAP请求的主体发送XML,就像最初一样。

如果您确实需要发送整个SOAP信封,则需要考虑使用MimeMessage作为请求负载:https://docs.spring.io/spring-integration/docs/5.0.6.RELEASE/reference/html/ws.html#mtom-支持

相关内容

  • 没有找到相关文章

最新更新