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