我尝试构建一个简单的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信封头,而不是信封主体。例如:
休息请求:
{
"foo": "foo",
"bar": "bar"
}而SOAP请求应该是:
<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>我怎么能这么做?转换器只创建soap主体,而在拦截器或标头映射程序中,我不再有原始请求。有什么办法吗?
发布于 2018-10-29 13:41:54
见文献资料。
WS消息头 Spring网关将自动映射SOAP头。默认情况下,将使用MessageHeaders将其复制到Spring和从Spring复制。 当然,您可以传递自己的SOAP特定头映射器的实现,因为网关有各自的属性来支持该实现。 除非由requestHeaderNames和/或replyHeaderNames属性显式指定,否则任何用户定义的SOAP标头都不会复制到SOAP消息或从SOAP消息中复制。 ..。
https://stackoverflow.com/questions/53042199
复制相似问题