axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Pfeifer" <john.pfei...@hnpsolutions.com>
Subject How do I create Custom Faults
Date Mon, 02 Oct 2006 21:06:51 GMT

I am attempting to create a simple web service that throws a custom exception but I haven't
found anything in the apache documents that clearly outlines how to do this.  It seems that
there are two approaches to creating a web service, the first is to define an implementation
class and configure it in the service.xml.  This approach doesn't require a wsdl, so I am
not quite sure how to define custom Faults.

For example, the MyService example defines a method like so... Also, I tried throwing a custom
Fault which extends AxisFault.. The results are the same...  I get something like this, which
isn't very discriptive.

    public void pingF(OMElement element) throws AxisFault{

        throw new AxisFault("Fault being thrown");

    }

<soapenv:Fault><faultcode>soapenv:Client</faultcode>"
2006/10/02 16:38:13:902 EDT [DEBUG] content - -<< "[\r]"
2006/10/02 16:38:13:902 EDT [DEBUG] content - -<< "[\n]"
2006/10/02 16:38:13:903 EDT [DEBUG] content - -<< "0"
2006/10/02 16:38:13:903 EDT [DEBUG] content - -<< "0"
2006/10/02 16:38:13:903 EDT [DEBUG] content - -<< "2"
2006/10/02 16:38:13:903 EDT [DEBUG] content - -<< "2"
2006/10/02 16:38:13:903 EDT [DEBUG] content - -<< "[\r]"
2006/10/02 16:38:13:903 EDT [DEBUG] content - -<< "[\n]"
2006/10/02 16:38:13:903 EDT [DEBUG] content - -<< "<faultstring>unknown</faultstring>"
2006/10/02 16:38:13:907 EDT [DEBUG] content - -<< "[\r]"
2006/10/02 16:38:13:907 EDT [DEBUG] content - -<< "[\n]"
2006/10/02 16:38:13:907 EDT [DEBUG] content - -<< "0"
2006/10/02 16:38:13:907 EDT [DEBUG] content - -<< "6"
2006/10/02 16:38:13:907 EDT [DEBUG] content - -<< "f"
2006/10/02 16:38:13:908 EDT [DEBUG] content - -<< "b"
2006/10/02 16:38:13:908 EDT [DEBUG] content - -<< "[\r]"
2006/10/02 16:38:13:908 EDT [DEBUG] content - -<< "[\n]"
2006/10/02 16:38:13:908 EDT [DEBUG] content - -<< "<detail><Exception>org.apache.axis2.AxisFault[\n]"
2006/10/02 16:38:13:908 EDT [DEBUG] content - -<< "[0x9]at org.apache.axis2.receivers.RawXMLINOutMessageReceiver.invo



The other method is to generate the code from an existing WSDL.  While this approach creates
custom fault objects for you, I don't like the fact that it generates so many classes.

So I guess my question how can I create custom faults without generating the code from a WSDL...
Also, If I stick with my current implementation I would still like to publish a WSDL, but
it doesn't look like apache creates a wsdl for document literal web services.  Do I have to
code this by hand?

jp4

Mime
View raw message