Hi Dushan/Dev
I tried ur solution and its work. but i have other question. when it catch
FAULT (500 error) on return message of client http code is 200 OK
for example let say endpoint is fail the it catch that fault. but in client
point of view http respond code of his response is 200

other than 500 client getting correct http response code. the problem may
be this is originate by ESB it self than come as response to ESB. btw is
there any solution for this.



On Sat, Feb 8, 2014 at 7:30 PM, Dushan Abeyruwan <[email protected]> wrote:

> Hi Kirshantha,
>   Handling fault has two flavors,
>
>    - Handle internal fault such as service EP not available and all the
>    issues related .
>    - Handle Service faults.
>
>
>  Ideally when BE is SOAP and if it returns SOAP fault in order to handle
> such queries we normally append FORCE_ERROR_ON_SOAP_FAULT property, this
> works only of BE return Service faults and when such happen if we need to
> divert such responses to the faultSequence that we have defined.
>    On the other hand if that is RESTful BE,  we do not have a inbuilt
> function  to determine whether its a fault at transport level, so the
> workaround that we normally do is to use the Filter base on the HTTP_SC.
>   If you look at [1] status codes represents 100 series and 200- series
> regards as non faulty responses, and other than that we can determine them
> as faults or defect, to overcome such station when deal with RESTful
> services personally I am using filters i.e
>
> OutSequence ..etc , below logic just evaluates the response and if that
> not falls between 200 series normally you can add your customize faulty
> response logic ..
>
>  <filter source="$axis2:HTTP_SC" regex="^[^2][0-9][0-9]">
>             <then>
>                <log level="custom">
>
>    - can include payload
>       - can setup HTTP_SC to axis2 context
>       - can use <respond> mediator to reply client with error.
>
>                  ..............
>                  ..............
>
>             </then>
>          </filter>
>
>
> [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>
>
>
>
>
> On Fri, Feb 7, 2014 at 7:54 PM, Krishantha Dinesh <[email protected]>wrote:
>
>> I have used following code to handle error on soap call
>>
>> proxy
>> ==============
>>
>> <faultSequence>
>>             <makefault version="soap11">
>>                 <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope";
>>                     value="get-property('FAULT_CODE')" />
>>                 <reason expression="get-property('ERROR_CODE')" />
>>                 <detail expression="get-property('ERROR_MESSAGE')" />
>>             </makefault>
>>             <send />
>>         </faultSequence>
>>
>> Output
>> ==============
>> <soapenv:Envelope xmlns:soapenv="
>> http://schemas.xmlsoap.org/soap/envelope/";>
>>    <soapenv:Body>
>>       <soapenv:Fault>
>>          <faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope
>> ">123456</faultcode>
>>          <faultstring>abc</faultstring>
>>          <detail>xyz</detail>
>>       </soapenv:Fault>
>>    </soapenv:Body>
>> </soapenv:Envelope>
>>
>>
>> I need to know what is the best approach to handle exception on REST
>> calls.
>>
>> i tried to apply same way just for try but it only give ERROR_MESSAGE not
>> another...
>>
>> my expectation is to deliver all exception to client (caller). eg:
>> transport error due to unavailable endpoint.. etc
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Dushan Abeyruwan | Associate Tech Lead
> Integration Technologies Team
> PMC Member Apache Synpase
> WSO2 Inc. http://wso2.com/
> Blog:http://dushansview.blogspot.com/
> Mobile:(0094)713942042
>
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to