在Spring集成中使用REST调用的XML响应
这似乎是一项简单的任务,但我无法控制它 我有一个Spring集成链,它调用一个外部Web服务,返回一个XML。我希望在下游XpathRouter中使用该XML响应 我应该使用什么样的预期响应类型在Spring集成中使用REST调用的XML响应,spring,spring-integration,Spring,Spring Integration,这似乎是一项简单的任务,但我无法控制它 我有一个Spring集成链,它调用一个外部Web服务,返回一个XML。我希望在下游XpathRouter中使用该XML响应 我应该使用什么样的预期响应类型 <int:chain input-channel="filesChannel"> <!-- ... some previous components in the chain --> <int-http:outbound-gateway h
<int:chain input-channel="filesChannel">
<!-- ... some previous components in the chain -->
<int-http:outbound-gateway
http-method="POST"
url="http://web/service/url"
expected-response-type="java.lang.String" />
<int-xml:xpath-router default-output-channel="resultChannel">
<int-xml:xpath-expression expression="/order/status" />
<int-xml:mapping value="Error" channel="importErrorChannel" />
</int-xml:xpath-router>
</int:chain>
该节点为空,尽管消息中确实包含有效的XML
是因为我没有设置正确的预期响应类型
以下是我从服务收到的响应XML:
<apiResponse version="1.0">
<orders>
<order>
<orderReference>test_2_3045342</orderReference>
<status>Error</status>
<errors>
<error>
<errorCode>1100</errorCode>
<errorMessage><![CDATA[ "Field is required: dropWindow" ]]></errorMessage>
</error>
</errors>
</order>
</orders>
</apiResponse>
测试2_3045342
错误
1100
好的,我发现了我的错误-它实际上在XPATH表达式中。它应该是//order/status
以启用深度搜索
java.lang.String
expected响应类型适用于XML XpathRouter
谢谢
<apiResponse version="1.0">
<orders>
<order>
<orderReference>test_2_3045342</orderReference>
<status>Error</status>
<errors>
<error>
<errorCode>1100</errorCode>
<errorMessage><![CDATA[ "Field is required: dropWindow" ]]></errorMessage>
</error>
</errors>
</order>
</orders>
</apiResponse>