我的目标是将返回soap错误的消息放到队列中,以便稍后重试。
我几乎都在工作,但最重要的部分是:我无法从代理的故障序列访问原始消息:
我首先创建了一个代理服务,该服务返回给定值的错误,或者对其他值返回OK:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxyService" transports="http https" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="custom">
<property name="TestProxyService" value="InSequence"/>
</log>
<switch xmlns:bnc="http://bnc.org/" source="//bnc:id">
<case regex="1">
<log level="custom">
<property name="TestProxyService" value="Send Error !"/>
</log>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
<reason value="ERROR ERROR ERROR"/>
<detail>ERROR</detail>
</makefault>
<respond/>
</case>
<default>
<log level="custom">
<property name="TestProxyService" value="No Error"/>
</log>
<log level="custom">
<property name="id" expression="//bnc:id"/>
</log>
<payloadFactory media-type="xml">
<format>
<bnc:response>OK</bnc:response>
</format>
<args/>
</payloadFactory>
<respond/>
</default>
</switch>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>而且效果很好
然后,我做了另一个代理,它使用第一个代理作为端点来测试队列中的错误:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="QueuingProxyService" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
<send>
<endpoint key="TestProxyServiceEndpoint"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence>
<store messageStore="No1MessageStore"/>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
<reason value="There has been an error"/>
<detail>We will retry later</detail>
</makefault>
<send/>
</faultSequence>
</target>
</proxy>存储的消息是由TestProxy中的makefault生成的消息。
我尝试将原始消息保存在属性中(在inSequence中)
<property name="OriginalBody" expression="$body" scope="axis2" type="OM"/>但是在faultSequence,当我这么做的时候:
<log level="custom">
<property name="OriginalBody" expression="get-property('OriginalBody')"/>
</log>因此,我得到了空:
有谁有主意吗?
谢谢!
发布于 2015-06-03 18:06:06
在定义属性"axis2“时删除范围"OriginalBody”,或明确指定scope=“默认”:
<property name="OriginalBody" expression="$body" type="OM"/>https://stackoverflow.com/questions/30618443
复制相似问题