Hello All,
is there a best pratice how to handle exceptions in webservices as provider and consumer.
e.g.: handle the exception in the flow and return to caller only an error code but no exception or throw an exception?
Hello All,
is there a best pratice how to handle exceptions in webservices as provider and consumer.
e.g.: handle the exception in the flow and return to caller only an error code but no exception or throw an exception?
When you are working with Webservices you need to take care about two aspects, SOAP exception (fault) and the service exception.
Handling of soap exception becomes neccessary while acting as consumer, as the return can be SOAP-Response or SOAP-Fault so proper handling shd be done. This can be done by braching on soap-fault string…
Apart from SOAP fault, service exception/error handling is required to catch and throw custom/application/system errors.
error handling sometimes depends on the customer for webservices and there are several scenarios, say we have the below scenario
Consumer → ESB Producer → ESB Consumer → Actual Producer
It is good to have error block in soap response message to pass the errors softly.
At ESB Consumer:
At ESB producer:
Apart from this it is always good to maintain list of errors that can be re-tried as in some realtime applications we do not want to re-try within ESB but inform consumer that this request can be re-tried again.
in general, always better to handle exception/errors and process as per our requirements.