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 handling SOAP fault in JAVA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "handling SOAP fault in JAVA" Watch "handling SOAP fault in JAVA" New topic

handling SOAP fault in JAVA

Puja Mantri

Joined: Sep 24, 2009
Posts: 15

Application 1 is calling the webservice from Application 2. If there is some problem in executing the webservice application 2 will send the SOAP Fault. My question is -

How to handle the SOAP fault in JAVA (on Application 1 side) ?

We are using Spring webservice.

Currently webservice that we are going to call is not up so not able to do the experiment. Please guide.

Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1183

One of the nice things about SOAP is the fact that the structure of the faults is predefined as we can see at SOAP Fault Element.
With Firefow Poster you can simulate the situation and work on the Java code the processes these faults.


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi Puja,
It's good that you said which web service API you are using. But, it really doesn't matter when dealing with SOAP Faults!

Based on your details, I understand your Application 1 is acting as "client" to Application 2. Then you must have created your client stubs using Application 2 WSDL. If your Application 2 WSDL is defined with one or more SOAP faults, then your client stubs correspondingly contain methods throwing SOAP faults. For you, catching SOAP faults is like catching any other checked exceptions (viz. SQLException). SOAP fault details (like in Dan's reply) can be accessed by invoking methods on exception object.

(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Shashank Ag
Ranch Hand

Joined: Dec 22, 2009
Posts: 88

Spring has a capability to specify Soap Fault Handeler.
Here is link you may like to see:

SCJP 91%, SCWCD 97%
Puja Mantri

Joined: Sep 24, 2009
Posts: 15
thank you everyone. that helps.

I agree. Here's the link:
subject: handling SOAP fault in JAVA
jQuery in Action, 3rd edition