• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

web service exception handling..

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

i am using the axis ver 1.4 to call web service, the calling is fine in normal case. say i send out a request and get a response.

but when there is error return. the error message seem include in response message without throw any exceptions. i do set up catch (Exception e){} but without hitting it.

e.g.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.net.ConnectException: Connection timed out: connect</faultstring>
<detail>
<ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">java.net.ConnectException: Connection timed out: connect
....
at InstantCashTester.main(InstantCashTester.java:97)
</ns1:stackTrace>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">pc-host</ns2:hostname>
</detail></soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

i would like to ask how to catch the web service exception (such as the connection timed out exception) or should i parse the response xml and detect it the fault value by self??
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
As far as I know, different web service stacks handle faults differently.
If your web service stack is JAX-WS compliant, then have a look at section 3.7 in the JAX-WS Specifications 2.1 for details.
JAX-WS translates service-specific exceptions to faults, which at the client side are again translated to exceptions.
In your case, there seem to be no translation at the client side, so you will most likely have to examine the incoming responses for faults. This can be done in a handler.
Best wishes!
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As per my understanding whenever there is fault response axis client throws fault exception, so it should not be a problem. I did further research and could find out a flag in axis2 which decides client behaviour in case of soap fault.


public class Options implements Externalizable {
/**
* If there is a SOAP Fault in the body of the incoming SOAP Message, system
* can be configured to throw an exception with the details extracted from
* the information from the fault message. This boolean variable will enable
* that facility. If this is false, the response message will just be
* returned to the application, irrespective of whether it has a Fault or
* not.
*
* @param exceptionToBeThrownOnSOAPFault
*/
public void setExceptionToBeThrownOnSOAPFault(
boolean exceptionToBeThrownOnSOAPFault) {
isExceptionToBeThrownOnSOAPFault = Boolean
.valueOf(exceptionToBeThrownOnSOAPFault);
}
}



 
Replace the word "snake" with "danger noodle" in all tiny ads.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic