axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amila Suriarachchi" <amilasuriarach...@gmail.com>
Subject Re: exception handling, chicken and egg?
Date Fri, 24 Aug 2007 04:34:16 GMT
There is no relationship with the initial class exception in your service
and the wsdl2java generated Exception.
Let me explain you this clearly.

Lets take your senario. you have this java class.
public class MyService {
     public boolean myOperation(String param) throws MyException;
}

when you deploy this class as a web service it generates you the wsdl for
this service.
This generated wsdl contains a fault element for the myOperation.

When using wsdl2java it only concern about that fact. Only the wsdl. it does
not know or care about the way you have implement the service. So it
generates an Exception class for that fault message.

Now as you can see these two exception classes are different
classes(although they have the same name).

If you want to use the same exception class and other classes at the client
side you have to use the RPCServiceClient instead of wsdl2java codegen. But
the problem with RPCServiceClient is it does not handle exceptions
correctly.
So if you want to have the same exception class at the client side only
option is to use the Axis2-rmi (this is only available at nighly builds).

So for your problem either you have to use two Exception classes (original
and wsdl2java generated) at the client side and server side or have to
switch to Axis2-rmi.

Amila.



On 8/24/07, Justin Sands <jsands@biobex.com> wrote:
>
>  I am trying to do some basic exception handling with axis 2 (Using a POJO
> for my service).  It looks accomplishing this even in the most basic case
> introduces circular dependencies.
>
> Is there a clear build pattern that will avoid this?
> Must I hand code my wsdl before I start?
> What do people do to avoid this?
>
> For example:
> ========================================
> public class MyService {
>      public boolean myOperation(String param) throws MyException;
> }
>
> All I want to do is generate a test client that has some code like this
> (as in the fault handling sample):
>
>   try {
>     MyServiceStub.MyOperation request = new MyServiceStub.MyOperation();
>     request.setParam("13");
>     stub.myOperation()
>    }
>    catch (MyException exception) {
>      // hande my exception
>    }
>
> This does not work as I get an AxisFault instead of MyException
>
> I've looked at the samples/faulthandling example.
> Why must the MyException class be autogenerated?
>  Is it strictly required that the service throws the autogenerated
> MyException?
>
>  ========================================
> I want a nice clean feed forward build process::
>
>   MyService.java -> [javac] -> MyService.class ->
>           [java2wsdl] -> MyServiceMyService.wsdl ->
>           [wsdl2java] -> MyClientStub.java
>
>  However, in order to compile MyService.java I need to the exception
> defined, compile my classes, and then
> generate my wsdl.  I can certainly define a temporary MyException, but it
> must be deleted after the service is built, (as in the faulthandling
> example) or I will get duplicate classes.
>
> I'm sure there is a simple way to do this.
>
>  Thanks
>    - Justin
>



-- 
Amila Suriarachchi,
WSO2 Inc.

Mime
View raw message