Spring 集成:如何 post 使用 http 出站网关请求参数
Spring integration: How to post request params with http outbound gateway
我正在尝试通过 Spring 集成调用 REST Web 服务,即 Spring 集成将充当我的 REST Web 服务的客户端。但是,我应该将参数添加到 ws url 并将 json 对象添加为参数。
为此,我尝试了以下配置:
<int:enricher input-channel="inputChannel" request-channel="quakeinfotrigger.channel">
<int:property name="info" expression="payload"/>
</int:enricher>
<int-http:outbound-gateway id="quakerHttpGateway"
request-channel="quakeinfotrigger.channel"
url="http://ffff.ff/gg/rest/put/{tel_number}"
http-method="PUT"
expected-response-type="java.lang.String"
charset="UTF-8"
reply-timeout="5000"
reply-channel="quakeinfo.channel">
<int-http:uri-variable name="tel_number" expression="payload.getNumTelefono()"/>
</int-http:outbound-gateway>
tel_number 没有作为参数传递,你能给我一个通过 url 和 json 对象将参数作为字符串传递的解决方案吗?
"tel_number is not passed as a param" 是什么意思?
我刚刚将 http sample 修改为:
<int:gateway id="requestGateway"
service-interface="org.springframework.integration.samples.http.RequestGateway"
default-request-channel="requestChannel">
<int:default-header name="content-type" value="application/json" />
</int:gateway>
<int:channel id="requestChannel"/>
<int-http:outbound-gateway request-channel="requestChannel"
url="http://localhost:8080/http/receiveGateway/{tel_num}"
http-method="POST"
expected-response-type="java.lang.String">
<int-http:uri-variable name="tel_num" expression="'foo'" />
</int-http:outbound-gateway>
它按预期工作 - 服务器端,我明白了
No mapping found for HTTP request with URI [/http/receiveGateway/foo]
不清楚你问的是什么JSON;如果您在有效负载中发送一个 POJO 并将 content-type
header 设置为 'application/json'(使用 header-enricher)并将 Jackson 罐子放在类路径中,它就会正常工作。
我正在尝试通过 Spring 集成调用 REST Web 服务,即 Spring 集成将充当我的 REST Web 服务的客户端。但是,我应该将参数添加到 ws url 并将 json 对象添加为参数。 为此,我尝试了以下配置:
<int:enricher input-channel="inputChannel" request-channel="quakeinfotrigger.channel">
<int:property name="info" expression="payload"/>
</int:enricher>
<int-http:outbound-gateway id="quakerHttpGateway"
request-channel="quakeinfotrigger.channel"
url="http://ffff.ff/gg/rest/put/{tel_number}"
http-method="PUT"
expected-response-type="java.lang.String"
charset="UTF-8"
reply-timeout="5000"
reply-channel="quakeinfo.channel">
<int-http:uri-variable name="tel_number" expression="payload.getNumTelefono()"/>
</int-http:outbound-gateway>
tel_number 没有作为参数传递,你能给我一个通过 url 和 json 对象将参数作为字符串传递的解决方案吗?
"tel_number is not passed as a param" 是什么意思?
我刚刚将 http sample 修改为:
<int:gateway id="requestGateway"
service-interface="org.springframework.integration.samples.http.RequestGateway"
default-request-channel="requestChannel">
<int:default-header name="content-type" value="application/json" />
</int:gateway>
<int:channel id="requestChannel"/>
<int-http:outbound-gateway request-channel="requestChannel"
url="http://localhost:8080/http/receiveGateway/{tel_num}"
http-method="POST"
expected-response-type="java.lang.String">
<int-http:uri-variable name="tel_num" expression="'foo'" />
</int-http:outbound-gateway>
它按预期工作 - 服务器端,我明白了
No mapping found for HTTP request with URI [/http/receiveGateway/foo]
不清楚你问的是什么JSON;如果您在有效负载中发送一个 POJO 并将 content-type
header 设置为 'application/json'(使用 header-enricher)并将 Jackson 罐子放在类路径中,它就会正常工作。