在基于 oh SOAP 响应的 WSO2 ESB 代理服务中切换 OutSequence
Switching OutSequence in WSO2 ESB Proxy Service based oh SOAP response
我在 WSO2 ESB 中部署了一个代理服务,用于从 SOAP WS 检索数据集,并且我有一个基于调用模板的序列的 OutSequence。
我必须根据在 vfs 传输写入的不同文件上路由它们的不同请求来引导各种 WS 响应。
实际顺序如下:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="seq_prova_con_template">
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"></with-param>
</call-template>
</sequence>
我考虑使用 switch-case 调解器,但我想了解如何 "catch" 选择正确案例的信息。在示例中:
`<switch source="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples/xsd">
<case regex="IBM">
<!-- the property mediator sets a local property on the *current* message -->
<property name="symbol" value="Great stock - IBM"/>
</case>
<case regex="MSFT">
<property name="symbol" value="Are you sure? - MSFT"/>
</case>
<default>
<!-- it is possible to assign the result of an XPath or JSON Path expression as well -->
<property name="symbol"
expression="fn:concat('Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)"
xmlns:m0="http://services.samples/xsd"/>
</default>
`
我问自己如何设置 switch case 的源参数,我想知道是否有人已经实现了这样的解决方案,以便使用单个代理服务来区分来自 WS 的各种答案.
我的顺序如下:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="seq_template_switch">
<switch xmlns:ns="http://org.apache.synapse/xsd" xmlns:m0="http://services.samples" source="??????">
<case regex="QueryStructure">
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"></with-param>
</call-template>
</case>
<case regex="GetCompactData">
<call-template target="file">
<with-param name="filename" value="GetCompactData-template.xml"></with-param>
</call-template>
</case>
</switch>
</sequence>
我需要从我的请求消息的请求中的 che 方法中捕获 switch case 的选择,以便在我要求一种答案时写入某个文件,而在请求时写入另一个名称不同的文件我要求另一种答案。
[编辑] 日志文件有这个:
TID: [0] [ESB] [2015-09-18 10:33:09,125] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:7cc540d3-2893-4b0e-8a24-ab4538236d45, Direction: response, Envelope: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><QueryStructureResponse xmlns="http://ec.europa.eu/eurostat/sri/service/2.0"><QueryStructureResult><RegistryInterface xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"><Header><ID>IT1001</ID><Test>true</Test><Name xml:lang="en">ISTAT_JD_237</Name><Prepared>2001-03-11T15:30:47+01:00</Prepared><Sender id="ISTAT"><Name xml:lang="en">Italian Statistical Institute</Name><Contact>
关于标签 <QueryStructureResponse>
选择 switch/case 中介器会很有用。例如,我可以用 <GetCompactData>
代替这个标签。我想创建一个由这两个标签之一驱动的 switch/case 调解器。这将是理解如何使用 XPath 位置和使用单个序列通过 vfs 区分不同文件中的 SOAP 答案的良好开端 transport.The 要写入的文件的选择将由 WS 的答案类型决定.
以下应该适合您。它正在检查 QueryStructureResponse 是否存在于 SOAP xml 中。如果可用,那么它将调用 IstatAllDataflow-template.xml 模板,否则它将调用 GetCompactData-template.xml 模板。
<switch source="boolean($body//*[local-name() = 'QueryStructureResponse'])">
<case regex="true">
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"></with-param>
</call-template>
</case>
<case regex="false">
<call-template target="file">
<with-param name="filename" value="GetCompactData-template.xml"></with-param>
</call-template>
</case>
</switch>
在 WSO2 esb 中使用过滤器的另一种解决方案。
<filter source="boolean($body//*[local-name() = 'QueryStructureResponse'])" regex="true">
<then>
<log>
<property name="======================== TRUE =========================" value="true"/>
</log>
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"/>
</call-template>
</then>
<else>
<log>
<property name="==================== FALSE =========================" value="false"/>
</log>
<call-template target="file">
<with-param name="filename" value="GetCompactData-template.xml"/>
</call-template>
</else>
</filter>
我在 WSO2 ESB 中部署了一个代理服务,用于从 SOAP WS 检索数据集,并且我有一个基于调用模板的序列的 OutSequence。
我必须根据在 vfs 传输写入的不同文件上路由它们的不同请求来引导各种 WS 响应。
实际顺序如下:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="seq_prova_con_template">
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"></with-param>
</call-template>
</sequence>
我考虑使用 switch-case 调解器,但我想了解如何 "catch" 选择正确案例的信息。在示例中:
`<switch source="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples/xsd">
<case regex="IBM">
<!-- the property mediator sets a local property on the *current* message -->
<property name="symbol" value="Great stock - IBM"/>
</case>
<case regex="MSFT">
<property name="symbol" value="Are you sure? - MSFT"/>
</case>
<default>
<!-- it is possible to assign the result of an XPath or JSON Path expression as well -->
<property name="symbol"
expression="fn:concat('Normal Stock - ', //m0:getQuote/m0:request/m0:symbol)"
xmlns:m0="http://services.samples/xsd"/>
</default>
`
我问自己如何设置 switch case 的源参数,我想知道是否有人已经实现了这样的解决方案,以便使用单个代理服务来区分来自 WS 的各种答案. 我的顺序如下:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="seq_template_switch">
<switch xmlns:ns="http://org.apache.synapse/xsd" xmlns:m0="http://services.samples" source="??????">
<case regex="QueryStructure">
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"></with-param>
</call-template>
</case>
<case regex="GetCompactData">
<call-template target="file">
<with-param name="filename" value="GetCompactData-template.xml"></with-param>
</call-template>
</case>
</switch>
</sequence>
我需要从我的请求消息的请求中的 che 方法中捕获 switch case 的选择,以便在我要求一种答案时写入某个文件,而在请求时写入另一个名称不同的文件我要求另一种答案。
[编辑] 日志文件有这个:
TID: [0] [ESB] [2015-09-18 10:33:09,125] INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:7cc540d3-2893-4b0e-8a24-ab4538236d45, Direction: response, Envelope: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><QueryStructureResponse xmlns="http://ec.europa.eu/eurostat/sri/service/2.0"><QueryStructureResult><RegistryInterface xmlns="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"><Header><ID>IT1001</ID><Test>true</Test><Name xml:lang="en">ISTAT_JD_237</Name><Prepared>2001-03-11T15:30:47+01:00</Prepared><Sender id="ISTAT"><Name xml:lang="en">Italian Statistical Institute</Name><Contact>
关于标签 <QueryStructureResponse>
选择 switch/case 中介器会很有用。例如,我可以用 <GetCompactData>
代替这个标签。我想创建一个由这两个标签之一驱动的 switch/case 调解器。这将是理解如何使用 XPath 位置和使用单个序列通过 vfs 区分不同文件中的 SOAP 答案的良好开端 transport.The 要写入的文件的选择将由 WS 的答案类型决定.
以下应该适合您。它正在检查 QueryStructureResponse 是否存在于 SOAP xml 中。如果可用,那么它将调用 IstatAllDataflow-template.xml 模板,否则它将调用 GetCompactData-template.xml 模板。
<switch source="boolean($body//*[local-name() = 'QueryStructureResponse'])">
<case regex="true">
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"></with-param>
</call-template>
</case>
<case regex="false">
<call-template target="file">
<with-param name="filename" value="GetCompactData-template.xml"></with-param>
</call-template>
</case>
</switch>
在 WSO2 esb 中使用过滤器的另一种解决方案。
<filter source="boolean($body//*[local-name() = 'QueryStructureResponse'])" regex="true">
<then>
<log>
<property name="======================== TRUE =========================" value="true"/>
</log>
<call-template target="file">
<with-param name="filename" value="IstatAllDataflow-template.xml"/>
</call-template>
</then>
<else>
<log>
<property name="==================== FALSE =========================" value="false"/>
</log>
<call-template target="file">
<with-param name="filename" value="GetCompactData-template.xml"/>
</call-template>
</else>
</filter>