【发布时间】:2014-08-04 16:14:12
【问题描述】:
我有一个入站网关来处理 JSON 负载。由于我们使用与 SOAP 端点相同的后端服务,因此我需要一个映射到所有路径的入站网关。我可以看到默认的 HTTP 标头出现在消息中,但我特别需要请求 URL,以便我可以解析它并根据需要路由到适当的服务。
我的入站网关:
<int-http:inbound-gateway id="JSONGateway"
path="*" request-channel="JSONRequestChannel" supported-methods="POST"
reply-timeout="5000"
header-mapper="headerMapper"
request-payload-type="java.lang.String" >
</int-http:inbound-gateway>
我尝试像添加 SOAP 一样添加标头丰富器,但 TransportContextListener 为空。
<int:header-enricher input-channelJSONequestChannel"
output-channel="JSONRequestChannelWithHeaders">
<int:header name="service"
expression="T(org.springframework.ws.transport.context.TransportContextHolder).transportContext.connection.uri.toString().substring(T(org.springframework.ws.transport.context.TransportContextHolder).transportContext.connection.uri.toString().lastIndexOf('/')+1)" />
</int:header-enricher>
我需要一种方法来获取请求的 URL,以便我可以将服务解析到下游路由器的消息头中。
/json/ContactService = "ContactService"
/json/ContactService/insert = "ContactService"
/json/ContactService/get/234 = "ContactService"
我也尝试添加一个 header-mapper 类,但仍然遇到同样的问题。如何在代码中获取 HTTPServletRequest 的句柄?一旦我得到它,我就可以获得我需要的所有标题。
【问题讨论】:
标签: spring-integration spring-ws