我尝试构建一个简单的 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>
我怎样才能做到这一点?转换器仅创建肥皂主体,而在拦截器或标头映射器中,我不再有原始请求。有没有办法做到这一点?