spring - 如何在 Spring Integration 中使用来自 int-http:inbound-gateway 的数据设置 SOAP Envelope Header?
问题描述
我尝试构建一个简单的 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>
我怎样才能做到这一点?转换器仅创建肥皂主体,而在拦截器或标头映射器中,我不再有原始请求。有没有办法做到这一点?
解决方案
请参阅文档。
WS 消息头
Spring Integration WebService 网关将自动映射 SOAP Action 标头。默认情况下,它将使用 DefaultSoapHeaderMapper 在 Spring Integration MessageHeaders 之间复制。
当然,您可以传入您自己的 SOAP 特定标头映射器实现,因为网关具有相应的属性来支持它。
除非 DefaultSoapHeaderMapper 的 requestHeaderNames 和/或 replyHeaderNames 属性明确指定,否则任何用户定义的 SOAP 标头都不会复制到 SOAP 消息中或从 SOAP 消息中复制。
...
推荐阅读
- docker - 运行 docker stack deploy 只是挂起
- android - Appium/wdio - 无法关闭 Android 上的位置权限警报
- html - 时事通讯的 CSS 代码显示在电子邮件的顶部。如何解决这个问题呢?
- spring-data - 如何使用spring数据规范查询jsonb列?
- angular - 如何在 Mat-Select 中实现搜索功能
- android - 在 android 应用程序中实现用户登录会话的最佳实践是什么?
- python - 如何在时间循环中将数据写入多个 csv 文件
- python - How to judge whether or not a given coordinate is in a certain city?
- ios - Apple watch 多个 Assets.xcassets 文件夹的用途
- r - 在对它们进行分组时使用数字作为列名