A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Web Services
Author
solution for extracting faultstring from SOAP FAULT EXCEPTION
prince davies
Ranch Hand
Joined: May 08, 2009
Posts: 74
posted
Dec 21, 2011 18:39:50
0
Help me to find out a good solution.
Is there any optimal way of extracting fault
string
from the SOAP FAULT EXCEPTION. i have provided my code how retrieved the fault string.
Parent and Children elements inside SOAP FAULT EXCEPTION
[ <con:errorCode>BEA-382500</con:errorCode>, <con:reason>yyyyyy</con:reason>,
<con:details>
<con1:ReceivedFaultDetail xmlns:con1="<http://www.bea.com/wli/sb/stages/transform/config>">
<con1:faultcode>soapenv:Server</con1:faultcode>
<con1:faultstring>ERR-666666 : error messsage here</con1:faultstring>
<con1:detail>
<ns7:
ServiceException
xmlns:S="<http://xsi:nil="true">
</ns7:
ServiceException
>
</con1:detail> <con1:http-response-code>500</con1:http-response-code> </con1:ReceivedFaultDetail>
</con:details>, <con:location><con:node>PipelinePairNode1</con:node><con:pipeline>PipelinePairNode1_request</con:pipeline><con:stage>checkAndDetermineBillingCycles1</con:stage><con:path>request-pipeline</con:path> </con:location>]
public static String getFaultString( SOAPFaultException soa) { String faultString =""; Iterator entries = getDetailEntries(soa); if( entries!=null ){ while ( entries.hasNext() ) { DetailEntry newEntry = (DetailEntry)entries.next(); if( newEntry!=null ){ final Iterator childElementsIter = newEntry.getChildElements(); if( childElementsIter!=null ){ while ( childElementsIter.hasNext() ) { final SOAPElement soapElement = (SOAPElement)childElementsIter.next(); String strName = getSOAPElementName(soapElement); if( strName!=null && strName.equals("details") ) { final Iterator childElementsIter1 = soapElement.getChildElements(); if( childElementsIter1!=null ){ while ( childElementsIter1.hasNext() ) { final SOAPElement soapElement1 =(SOAPElement)childElementsIter1.next(); String strName1 = getSOAPElementName(soapElement1); if( strName1!=null && strName1.equals("ReceivedFaultDetail") ) { final Iterator childElementsIter2 = soapElement1.getChildElements(); if( childElementsIter2!=null ){ while ( childElementsIter2.hasNext() ) { final SOAPElement soapElement2 =(SOAPElement)childElementsIter2.next(); String strName2 = getSOAPElementName(soapElement2); if( strName2!=null && strName2.equals("faultstring") ) { faultString = soapElement2.getValue(); break; } }//childElementsIter2 } } } //while childElementsIter1 } } } }// while childElementsIter } // newEntry }//while entries } return faultString; }
prince davies
Ranch Hand
Joined: May 08, 2009
Posts: 74
posted
Dec 24, 2011 09:44:14
0
XPATH SOLUTION
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
soa = (SOAPFaultException)fe.getCause();
Parent and Children elements inside SOAP FAULT EXCEPTION [ <con:errorCode>BEA-382500</con:errorCode>, <con:reason>yyyyyy</con:reason>, <con:details> <con1:ReceivedFaultDetail xmlns:con1="<http://www.bea.com/wli/sb/stages/transform/config>"> <con1:faultcode>soapenv:Server</con1:faultcode> <con1:faultstring>ERR-666666 : error messsage here</con1:faultstring> <con1:detail> <ns7:ServiceException xmlns:S="<http://xsi:nil="true"> </ns7:ServiceException> </con1:detail> <con1:http-response-code>500</con1:http-response-code> </con1:ReceivedFaultDetail> </con:details>, <con:location><con:node>PipelinePairNode1</con:node><con:pipeline>PipelinePairNode1_request</con:pipeline><con:stage>checkAndDetermineBillingCycles1</con:stage><con:path>request-pipeline</con:path> </con:location>]
Ivan Krizsan
Bartender
Joined: Oct 04, 2006
Posts: 2193
posted
Dec 25, 2011 07:23:49
0
Double-posting.
See this thread:
http://www.coderanch.com/t/562634/Web-Services/java/SOAPFaultException-EXTRACTING-FAULT-STRING-XPATH
Locking this thread.
My free books and tutorials:
http://www.slideshare.net/krizsan
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: solution for extracting faultstring from SOAP FAULT EXCEPTION
Similar Threads
ErrorHandling in Webservice client
Soap Fault Implementation
soap fault return empty <detail> element.
ErrorHandling in Webservice client
soapfaultexception
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter