我试图构建一个简单的spring集成项目,在该项目中我得到一个REST请求并将其转换为SOAP请求。像这样:
<int-http:inbound-gateway id="rest-inbound-gateway" request-channel="restRequestChannel"
reply-channel="restOutputChannel" supported-methods="POST"
path="/somepath" request-payload-type="com.something.RequestObject">
<int-http:request-mapping consumes="application/json" produces="application/json" />
</int-http:inbound-gateway>
<int:transformer ref="RestToSoapTransformer" method="transform"
input-channel="restRequestChannel" output-channel="transformedChannel"/>
<int-ws:outbound-gateway id="marshallingGateway"
request-channel="transformedChannel" reply-channel="restOutputChannel"
uri="http://localhost:8088/mockSoapBinding" marshaller="marshaller"
message-sender="messageSender"
unmarshaller="marshaller" >
</int-ws:outbound-gateway>
但是REST请求中的某些信息需要放入SAOP信封标头而不是信封主体。例如
REST请求:
{
"foo": "foo",
"bar": "bar"
}
而SOAP Request应该是:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<foo>foo</foo>
</soapenv:Header>
<soapenv:Body>
<bar>bar</bar>
</soapenv:Body>
</soapenv:Envelope>
我该怎么做?转换器仅创建肥皂主体,并且在拦截器或标头映射器中,我不再具有原始请求。有什么办法吗?
答案 0 :(得分:1)
WS消息标题
Spring Integration WebService网关将自动映射SOAP Action标头。默认情况下,将使用DefaultSoapHeaderMapper将其复制到Spring Integration MessageHeaders中以及从其中复制。
当然,您可以传入自己的SOAP特定标头映射器的实现,因为网关具有各自的属性来支持它。
除非由DefaultSoapHeaderMapper的requestHeaderNames和/或replyHeaderNames属性明确指定,否则任何用户定义的SOAP标头都不会复制到SOAP消息或从SOAP消息复制。
...