简体   繁体   中英

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. 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. 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. 2. Incase all the information are correct, the webservice is called properly and client gets the proper response.

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. So your InSequence will look like

<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. Following sample will also help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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