【问题标题】:Spring Integration ws-outbound-gateway throwing webservicetransportexception not-found-404 errorSpring Integration ws-outbound-gateway 抛出 webservicetransportexception not-found-404 错误
【发布时间】:2018-07-20 18:10:00
【问题描述】:

我们正在使用 ws-outbound-gateway 通过以下方式调用 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-outbound-gateway 将请求 xml 与soap Envelope 一起发送?

【问题讨论】:

    标签: spring spring-integration


    【解决方案1】:

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

    您的问题是您不必将完整的 SOAP 信封发送到 WS Outbound Gateway。您确实只需要为 SOAP 请求的主体发送 XML,就像您最初所做的那样。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-10
      • 1970-01-01
      相关资源
      最近更新 更多