简体   繁体   English

Wso2中介中的自定义错误处理程序

[英]Custom Error Handler in Wso2 Mediation

In my In sequence mediatior, I need to process some logic on the input values and based on that i need to decide whether to call the webservice or return a fault. 在我的顺序中介中,我需要对输入值进行一些逻辑处理,然后根据该逻辑确定是调用Web服务还是返回故障。 I have defined the sequence as following 我已经定义了以下顺序

<sequence xmlns="http://ws.apache.org/ns/synapse" name="m1">
    <class name="com.myclass">
    </class>
    <makefault version="soap11">
        <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:Client"/>
        <reason value="ERROR_MESSAGE"/>
        <role>Acc</role>
        <detail>Test Details</detail>
    </makefault>
    <log/>
</sequence>

The problem is by default the webservice is always passing fault information to the webservice. 问题是默认情况下,Web服务始终将故障信息传递到Web服务。 How do i make of the following 1. Incase the there is an custom exception thrown in Mediator, soap fault is thrown back to the webservice client. 我如何做到以下几点:1.如果Mediator中抛出了一个自定义异常,则肥皂错误将被抛出给Web服务客户端。 2. Incase all the information are correct, the webservice is called properly and client gets the proper response. 2.如果所有信息正确,则将正确调用Web服务,并且客户端将获得正确的响应。

You need to define a separate sequence to handle the faults. 您需要定义一个单独的顺序来处理故障。 Then, in your InSequence, you need to set that fault sequence to the "onError" attribute. 然后,在InSequence中,您需要将该故障序列设置为“ onError”属性。 So your InSequence will look like 因此您的InSequence看起来像

<sequence xmlns="http://ws.apache.org/ns/synapse" name="m1" onError="yourFaultSequence">
    <class name="com.myclass">
    </class>
    <log/>
    <send/>
</sequence>

Above configuration was added to give an idea. 上面的配置被添加以给出一个想法。 Note the onError attribute. 请注意,onError的属性。 Following sample will also help. 下面的示例也将有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM