File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Handle Exception in Web Service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Handle Exception in Web Service" Watch "Handle Exception in Web Service" New topic

Handle Exception in Web Service

Smita S. Mutha

Joined: Aug 05, 2008
Posts: 8

I am new to web services world.
Can someone please tell me how can I handle exception occered in Service.

If there is any exception while executing the service method code, if any exception occurs, may be run time exception or, some error condition, where custom message need to be sent back to user, how can one do it?

Can we send the exception/message in Soap:Fault. Or
I need to have some provision in return type of method.

Please help.

--------------------------------<br />SCJP (91%), SCWCD(89%)<br />ON the way to SCDJWS...
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Most SOAP toolkits will create a SOAP message with a Fault message.
The requirements for error handling are laid out in the by now very lengthy SOAP specification.

Be aware that if your request never gets through to your SOAP service due to some addressing problem, the server will probably send back a plain HTML message and an error code that your SOAP client may have a hard time interpreting.

Most developers use something like TCPMON to record the exact text of request and response when debugging.

I agree. Here's the link:
subject: Handle Exception in Web Service
It's not a secret anymore!