【发布时间】:2016-02-15 20:34:55
【问题描述】:
我有一个 REST 服务,我从我的 spring 上下文文件中调用它,并且根据收到的响应,我可以继续其余的处理,或者使用不同的 uri_variable 再次调用相同的服务。 下面是我的上下文文件-
<int:chain id="Search" input-channel="inputChannel" output-channel="channel1">
<int:header-enricher>
<int:header name="accept" value="application/xml" overwrite="true"/>
<int:header name="Authorization" method="getAuth" ref="Auth"/>
</int:header-enricher>
<int-xml:xpath-header-enricher>
<int-xml:header name="medId" xpath-expression="/MedicineFamily/medicineId/text()" evaluation-type="STRING_RESULT" />
</int-xml:xpath-header-enricher>
<int-http:outbound-gateway id="ServiceGateway" http-method="GET" reply-timeout="1000"
expected-response-type="java.lang.String" url="https://#{environment['dataservice.address']}:#{environment['dataservice.port']}/#{environment['dataservice.paths.medId']}"
mapped-request-headers="accept,Authorization" mapped-response-headers="medId" error-handler="ErrorHandler">
<int-http:uri-variable name="med_id" expression="headers['medId']"/>
</int-http:outbound-gateway>
<int:transformer ref="PharmacyBean" method ="formMed"/>
</int:chain>
在这里,我使用出站网关调用数据服务,其中 uri 变量作为从另一个服务调用接收到的 medId。现在根据这个服务的结果和在转换器中完成的处理,我可能需要再次调用这个服务,但这次使用不同的 uri 变量。
我怎样才能发回一个不同的变量并用这个新的 uri 变量再次调用这个服务? 另外,如果我返回了多个 medId 并且我想为其中的每一个调用该服务,我该如何循环调用该服务? 谢谢!
【问题讨论】: