我有REST服务,返回错误http 500(特别)。故障序列没有捕获此错误。如何捕获此错误?谢谢!
我的配置:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="d"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<send>
<endpoint>
<address uri="http://localhost:8080/rest/ris/b"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
<outSequence>
<send/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<log level="full"/>
</outSequence>
<faultSequence>
<log level="full">
<property name="MSG" value="==== FAULT CREATED ==="/>
</log>
<send/>
</faultSequence>
</target>
<description/>
</proxy>
答案 0 :(得分:2)
在outSequence中,当您收到REST服务的响应时,可以使用swith或filter mediator测试HTTP状态代码,示例:
<filter source="$axis2:HTTP_SC" regex="500">
<then>
...
</then>
<else>
...
</else>
</filter>
答案 1 :(得分:2)
作为一种解决方法,而不是使用<inSequence>
使用<inSequence onError="fault">
jira中记录了一个错误:
https://wso2.org/jira/browse/ESBJAVA-3386
请参阅故障单中附带的FORCE_ERROR_ON_SOAP_FAULT.xml
文件以获得更多说明