问题
I'm using Spring Integration in a project that integrates (successfully) various ReST/JSON and SOAP endpoints. Now I need to call a BusinessWorks instance that is configured to accept Plain-Old-Xml-over-HTTP. From the "Spring Integration in Action book", I got a hint that I should use int-ws:outbound-gateway for this. This configuration generates the correct request, but in SOAP:
<int-ws:outbound-gateway
uri="..."
request-channel="request" reply-channel="reply"
marshaller="marshaller" unmarshaller="unmarshaller"/>
I can't figure out how to configure this to send the object in the payload as POX (no SOAP envelope). I tried this:
<int-ws:outbound-gateway
uri="..."
request-channel="request" reply-channel="reply"
marshaller="marshaller" unmarshaller="unmarshaller"
message-factory="poxMessageFactory"/>
<bean id="poxMessageFactory"
class="org.springframework.ws.pox.dom.DomPoxMessageFactory"/>
The request seems to switch correctly to XML only but the body of the request is empty (no trace of the object present in the Spring Integration payload). Can someone tell me what I am doing wrong or how to achieve what I am trying to do?
回答1:
I think this is an omission in the AbstractWebServiceOutboundGateway
:
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
Object payload = this.requestMessage.getPayload();
if (message instanceof SoapMessage) {
this.doWithMessageInternal(message, payload);
AbstractWebServiceOutboundGateway.this.headerMapper
.fromHeadersToRequest(this.requestMessage.getHeaders(), (SoapMessage) message);
if (this.requestCallback != null) {
this.requestCallback.doWithMessage(message);
}
}
}
Pay attention to the if (message instanceof SoapMessage) {
.
So, indeed we miss there the fact that message can be different type.
Please, open JIRA bug on the matter.
Meanwhile as a workaround I would suggest you to use WebServiceTemplate
directly instead of <int-ws:outbound-gateway>
you can call it from the <service-activator>
using marshalSendAndReceive()
method for interaction.
来源:https://stackoverflow.com/questions/46592176/call-pox-web-service-from-spring-integration