This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes SOAPFaultException - EXTRACTING FAULT STRING using XPATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "SOAPFaultException - EXTRACTING FAULT STRING using XPATH" Watch "SOAPFaultException - EXTRACTING FAULT STRING using XPATH" New topic
Author

SOAPFaultException - EXTRACTING FAULT STRING using XPATH

prince davies
Ranch Hand

Joined: May 08, 2009
Posts: 74


I am getting SOAPFaultException on the fly and getting cause of the exception. This cause contains XML string to find out respective fault string.

How do i parse and feed soapfaultexception or cause into xpath methods?

How do I get value from the following node faultstring which is 3 layers down
detail
ReceivedFaultDetail
faultstring











Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
From the SOAPFaultException you can get a SOAPFault object, which contains information about the SOAP fault.
To obtain the data you mentioned in your posting, use the following methods on the SOAPFault object:
- Detail information: getDetail
This method will return a Detail object, which may contain multiple detail entries.
- Fault string: getFaultString

I don't know what ReceivedFaultDetail is, but I do not think it is necessary to use XPath to extract information from the SOAP fault.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
prince davies
Ranch Hand

Joined: May 08, 2009
Posts: 74
As you explained, I’m going to use the workaround that you mentioned in your post. But I'm stuck. Can you use my soapfaultexception provided in my previous post and write a code snippet for me to use it for my application. I’m not sure how do I get soapfault and retrieve the soap fault string. I need your guidance and a little bit of explanation. Perhaps i need your code. It will be greatly appreciated, if you spend a little bit of time to help me to resolve this issue and understanding that required for this resolution. In future, I can make use of your help that provided now in many places...

Sincerely thanking you. Only a few people turn their head towards the people who really in need.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Try this:

A Detail object obtained from the SOAPFault object is a DOM Node, so there are many opportunities to obtain information about the node etc etc.
The original question was how to obtain the SOAP fault string, which is what will be placed in the theSOAPFaultString after having executed the above code snippet.
Best wishes!
prince davies
Ranch Hand

Joined: May 08, 2009
Posts: 74
import javax.xml.soap.SOAPFault;

there is no method to get soapfault object from SOAPFaultException. There is a method getDetail() in SOAPFaultException. the one class I imported is as given above. How did you get
SOAPFault theFault = theException.getFault();

the following are the methods
getFaultActor()
getFaultCode()
getFaultString()

Can you please tell me which class you imported?

I presume that the faultstring retrieval that you mentioned above is at first layer. But mine is at a few layers down. You could see the xml string provided.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
I have been looking at the classes in the JavaSE 6 API only.
Which web service stack do you use?
Best wishes!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SOAPFaultException - EXTRACTING FAULT STRING using XPATH
 
Similar Threads
Soap Fault Implementation
solution for extracting faultstring from SOAP FAULT EXCEPTION
throwing our own soap fault code
soapfaultexception
Calling .NET webservice from java client