• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to throw and catch SOAP Fault in Axis2?

J Jensen
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am just trying to throw and catch a SOAP Fault (well, AxisFault) from a simple Axis2 web service.
The Axis2-1.3 distribution comes with a faulthanding example, but it seems rather complicated and has lots of auto generated classes. I am sure it is simpler than that.

Let's take the StockQuoteService example, in axis2-1.3\samples\quickstart. The client sends a string like "WSO" and the service returns a quote like "123.23". I'd like to send in the string "XYZ" and get the service to throw an AxisFault with a message, and the client catches it.

So what would I need to do? I'm guessing:

1. Modify StockQuoteService.java to have something like:
if( symbol.equals("XYZ")) throw
new AxisFault( new QName("http://test.org", "FaultCode", "test"),
new Exception("This is a test Exception"));

2. Put something in services.xml, but what??

3. Put a catch block in the client code
catch( AxisFault af)

Any help would be appreciated!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic