You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Fran <fc...@gmail.com> on 2007/06/05 10:45:17 UTC

[AXIS2] Throwing exceptions with ADB

Hi, list!

I have a problem throwing Exceptions from service to client, using ADB.

I create a service with Exceptions in some methods, I compile this
class and I create WSDL with Java2WSDL tool. In this WSDL I change
these lines:

<xs:element name="MyFault">
       <xs:complexType>
               <xs:sequence>
                       <xs:element name="message" type="xs:string" />
               </xs:sequence>
       </xs:complexType>
</xs:element>

So I can send a message to client in the fault, also I change the
services.xml file adding Faults to the respective methods.

And now I compile service like I do before change WSDL and all is ok,
but when I try to compile client, the client hasn't got the file of
MyFault class, it has only MyFaultException class.

My doubt is, do I have to copy manually the Fault class files? The
WSDL2Java tool has an option to create Fault class files in client
side, like it does in service side?

Thanks a lot!

-- 
Saludos

Fran

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [AXIS2] Throwing exceptions with ADB

Posted by Fran <fc...@gmail.com>.
2007/6/5, Raghu Upadhyayula <ru...@responsys.com>:
> Dims,
>
>         From the WSDL2Java documentation it says that -g option is only
> valid with the -ss (generate server side code) option.
>
>         But in Fran's case, he is generating the client code and he is
> not seeing the MyFault class but he is seeing the MyFaultException
> class.
>
> Fran,
>
>         I think the way WSDL2Java creates the fault classes is changed
> in Axis2, at least from what I saw when I generated my client code.
>
>         It doesn't generate the Fault class, but generates the
> FaultException class which has the Fault as a member in it.
>
>         To raise the exception on your Server side, you have to do this.
>         ----------------------------------------------------------------
>         MyFault fault = new MyFault();
>         MyFaultException faultEx = new MyFaultException();
>       fault.setMessage("Your Exception Message");
>         faultEx.setFaultMessage(fault);
>         throw faultEx;
>
>         To catch the Exception on your client side and get the exception
> msg.
>
> ---------------------------------------------------------------------
>         try {
>          ....
>         } catch (MyFaultException myFaultEx) {
>           System.out.println(myFaultEx.getFaultMessage().getMessage());
>             // getMessage returns your message set by the server
>       }
>
>         Hope this helps.
>
> Thanks
> Raghu
>
> -----Original Message-----
> From: Davanum Srinivas [mailto:davanum@gmail.com]
> Sent: Tuesday, June 05, 2007 6:12 AM
> To: axis-user@ws.apache.org
> Subject: Re: [AXIS2] Throwing exceptions with ADB
>
> Fran,
>
> Did you try "-g" option in wsdl2java when generating the client?
>
> thanks,
> dims
>
> On 6/5/07, Fran <fc...@gmail.com> wrote:
> > Hi, list!
> >
> > I have a problem throwing Exceptions from service to client, using
> ADB.
> >
> > I create a service with Exceptions in some methods, I compile this
> > class and I create WSDL with Java2WSDL tool. In this WSDL I change
> > these lines:
> >
> > <xs:element name="MyFault">
> >        <xs:complexType>
> >                <xs:sequence>
> >                        <xs:element name="message" type="xs:string" />
> >                </xs:sequence>
> >        </xs:complexType>
> > </xs:element>
> >
> > So I can send a message to client in the fault, also I change the
> > services.xml file adding Faults to the respective methods.
> >
> > And now I compile service like I do before change WSDL and all is ok,
> > but when I try to compile client, the client hasn't got the file of
> > MyFault class, it has only MyFaultException class.
> >
> > My doubt is, do I have to copy manually the Fault class files? The
> > WSDL2Java tool has an option to create Fault class files in client
> > side, like it does in service side?
> >
> > Thanks a lot!
> >
> > --
> > Saludos
> >
> > Fran
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>
> --
> Davanum Srinivas :: http://davanum.wordpress.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Thanks Raghu! Your code is just that I wanted, it works perfect!

-- 
Saludos

Fran

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [AXIS2] Throwing exceptions with ADB

Posted by James Englert <en...@gmail.com>.
That makes alot of sense.  This could be solved through betting tooling
also.  It would be very easy to write an IDE template to generate that
exception.

Thanks for the clarity.



> AFAIR the reason is that since we are supporting different databinding
> frameworks,  it is not always possible to generate a class that
> extends exception. The databinding tools only look at the schema and
> hence have no idea which elements are targeted towards exceptions.
> You can definitely tweak the ADB framework but it will be harder (if
> not impossible) to achieve this across all the other frameworks (such
> as XMLBeans, Jaxb , Jibx etc)
>
>

Re: [AXIS2] Throwing exceptions with ADB

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi,
AFAIR the reason is that since we are supporting different databinding
frameworks,  it is not always possible to generate a class that
extends exception. The databinding tools only look at the schema and
hence have no idea which elements are targeted towards exceptions.
You can definitely tweak the ADB framework but it will be harder (if
not impossible) to achieve this across all the other frameworks (such
as XMLBeans, Jaxb , Jibx etc)

So we have taken the generic path - where the exception contains the
databound object.

Ajith

On 6/5/07, James Englert <en...@gmail.com> wrote:
> As a side question, is there a way to avoid this:
>
> MyFault fault = new MyFault();
> MyFaultException faultEx = new MyFaultException();
> fault.setMessage("Your Exception Message");
> faultEx.setFaultMessage (fault);
> throw faultEx;
>
> in favor of
>
> MyFaultException faultEx = new MyFaultException();
> faultEx.setFaultMessage("Your Exception Here");
> throw faultEx;
>
> I see how this could be done by changing the templates that generate the
> axis code but that seems to be a poor practice IMO.   I assume there is a
> pretty good reason it wasn't done, any idea what that reason might be?
>
>
>
> On 6/5/07, Raghu Upadhyayula <ru...@responsys.com> wrote:
> > Dims,
> >
> >         From the WSDL2Java documentation it says that -g option is only
> > valid with the -ss (generate server side code) option.
> >
> >         But in Fran's case, he is generating the client code and he is
> > not seeing the MyFault class but he is seeing the MyFaultException
> > class.
> >
> > Fran,
> >
> >         I think the way WSDL2Java creates the fault classes is changed
> > in Axis2, at least from what I saw when I generated my client code.
> >
> >         It doesn't generate the Fault class, but generates the
> > FaultException class which has the Fault as a member in it.
> >
> >         To raise the exception on your Server side, you have to do this.
> >
> ----------------------------------------------------------------
> >         MyFault fault = new MyFault();
> >         MyFaultException faultEx = new MyFaultException();
> >       fault.setMessage("Your Exception Message");
> >         faultEx.setFaultMessage(fault);
> >         throw faultEx;
> >
> >         To catch the Exception on your client side and get the exception
> > msg.
> >
> >
> ---------------------------------------------------------------------
> >         try {
> >          ....
> >         } catch (MyFaultException myFaultEx) {
> >           System.out.println(myFaultEx.getFaultMessage().getMessage());
> >             // getMessage returns your message set by the server
> >       }
> >
> >         Hope this helps.
> >
> > Thanks
> > Raghu
> >
> > -----Original Message-----
> > From: Davanum Srinivas [mailto:davanum@gmail.com]
> > Sent: Tuesday, June 05, 2007 6:12 AM
> > To: axis-user@ws.apache.org
> > Subject: Re: [AXIS2] Throwing exceptions with ADB
> >
> > Fran,
> >
> > Did you try "-g" option in wsdl2java when generating the client?
> >
> > thanks,
> > dims
> >
> > On 6/5/07, Fran <fc...@gmail.com> wrote:
> > > Hi, list!
> > >
> > > I have a problem throwing Exceptions from service to client, using
> > ADB.
> > >
> > > I create a service with Exceptions in some methods, I compile this
> > > class and I create WSDL with Java2WSDL tool. In this WSDL I change
> > > these lines:
> > >
> > > <xs:element name="MyFault">
> > >        <xs:complexType>
> > >                <xs:sequence>
> > >                        <xs:element name="message"
> type="xs:string" />
> > >                </xs:sequence>
> > >        </xs:complexType>
> > > </xs:element>
> > >
> > > So I can send a message to client in the fault, also I change the
> > > services.xml file adding Faults to the respective methods.
> > >
> > > And now I compile service like I do before change WSDL and all is ok,
> > > but when I try to compile client, the client hasn't got the file of
> > > MyFault class, it has only MyFaultException class.
> > >
> > > My doubt is, do I have to copy manually the Fault class files? The
> > > WSDL2Java tool has an option to create Fault class files in client
> > > side, like it does in service side?
> > >
> > > Thanks a lot!
> > >
> > > --
> > > Saludos
> > >
> > > Fran
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> axis-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-user-help@ws.apache.org
> > >
> > >
> >
> >
> > --
> > Davanum Srinivas :: http://davanum.wordpress.com
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>


-- 
Ajith Ranabahu

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [AXIS2] Throwing exceptions with ADB

Posted by James Englert <en...@gmail.com>.
As a side question, is there a way to avoid this:

MyFault fault = new MyFault();
MyFaultException faultEx = new MyFaultException();
fault.setMessage("Your Exception Message");
faultEx.setFaultMessage(fault);
throw faultEx;

in favor of

MyFaultException faultEx = new MyFaultException();
faultEx.setFaultMessage("Your Exception Here");
throw faultEx;

I see how this could be done by changing the templates that generate the
axis code but that seems to be a poor practice IMO.   I assume there is a
pretty good reason it wasn't done, any idea what that reason might be?


On 6/5/07, Raghu Upadhyayula <ru...@responsys.com> wrote:
>
> Dims,
>
>         From the WSDL2Java documentation it says that -g option is only
> valid with the -ss (generate server side code) option.
>
>         But in Fran's case, he is generating the client code and he is
> not seeing the MyFault class but he is seeing the MyFaultException
> class.
>
> Fran,
>
>         I think the way WSDL2Java creates the fault classes is changed
> in Axis2, at least from what I saw when I generated my client code.
>
>         It doesn't generate the Fault class, but generates the
> FaultException class which has the Fault as a member in it.
>
>         To raise the exception on your Server side, you have to do this.
>         ----------------------------------------------------------------
>         MyFault fault = new MyFault();
>         MyFaultException faultEx = new MyFaultException();
>       fault.setMessage("Your Exception Message");
>         faultEx.setFaultMessage(fault);
>         throw faultEx;
>
>         To catch the Exception on your client side and get the exception
> msg.
>
> ---------------------------------------------------------------------
>         try {
>          ....
>         } catch (MyFaultException myFaultEx) {
>           System.out.println(myFaultEx.getFaultMessage().getMessage());
>             // getMessage returns your message set by the server
>       }
>
>         Hope this helps.
>
> Thanks
> Raghu
>
> -----Original Message-----
> From: Davanum Srinivas [mailto:davanum@gmail.com]
> Sent: Tuesday, June 05, 2007 6:12 AM
> To: axis-user@ws.apache.org
> Subject: Re: [AXIS2] Throwing exceptions with ADB
>
> Fran,
>
> Did you try "-g" option in wsdl2java when generating the client?
>
> thanks,
> dims
>
> On 6/5/07, Fran <fc...@gmail.com> wrote:
> > Hi, list!
> >
> > I have a problem throwing Exceptions from service to client, using
> ADB.
> >
> > I create a service with Exceptions in some methods, I compile this
> > class and I create WSDL with Java2WSDL tool. In this WSDL I change
> > these lines:
> >
> > <xs:element name="MyFault">
> >        <xs:complexType>
> >                <xs:sequence>
> >                        <xs:element name="message" type="xs:string" />
> >                </xs:sequence>
> >        </xs:complexType>
> > </xs:element>
> >
> > So I can send a message to client in the fault, also I change the
> > services.xml file adding Faults to the respective methods.
> >
> > And now I compile service like I do before change WSDL and all is ok,
> > but when I try to compile client, the client hasn't got the file of
> > MyFault class, it has only MyFaultException class.
> >
> > My doubt is, do I have to copy manually the Fault class files? The
> > WSDL2Java tool has an option to create Fault class files in client
> > side, like it does in service side?
> >
> > Thanks a lot!
> >
> > --
> > Saludos
> >
> > Fran
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
>
>
> --
> Davanum Srinivas :: http://davanum.wordpress.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

RE: [AXIS2] Throwing exceptions with ADB

Posted by Raghu Upadhyayula <ru...@responsys.com>.
Dims,

	From the WSDL2Java documentation it says that -g option is only
valid with the -ss (generate server side code) option.
	
	But in Fran's case, he is generating the client code and he is
not seeing the MyFault class but he is seeing the MyFaultException
class.

Fran,

	I think the way WSDL2Java creates the fault classes is changed
in Axis2, at least from what I saw when I generated my client code.
	
	It doesn't generate the Fault class, but generates the
FaultException class which has the Fault as a member in it.
	
	To raise the exception on your Server side, you have to do this.
	----------------------------------------------------------------
	MyFault fault = new MyFault();
	MyFaultException faultEx = new MyFaultException();
      fault.setMessage("Your Exception Message");
	faultEx.setFaultMessage(fault);
	throw faultEx;
	
	To catch the Exception on your client side and get the exception
msg.
	
---------------------------------------------------------------------
	try {
	 ....
	} catch (MyFaultException myFaultEx) {
          System.out.println(myFaultEx.getFaultMessage().getMessage());
	    // getMessage returns your message set by the server
      }
	
	Hope this helps.

Thanks
Raghu

-----Original Message-----
From: Davanum Srinivas [mailto:davanum@gmail.com] 
Sent: Tuesday, June 05, 2007 6:12 AM
To: axis-user@ws.apache.org
Subject: Re: [AXIS2] Throwing exceptions with ADB

Fran,

Did you try "-g" option in wsdl2java when generating the client?

thanks,
dims

On 6/5/07, Fran <fc...@gmail.com> wrote:
> Hi, list!
>
> I have a problem throwing Exceptions from service to client, using
ADB.
>
> I create a service with Exceptions in some methods, I compile this
> class and I create WSDL with Java2WSDL tool. In this WSDL I change
> these lines:
>
> <xs:element name="MyFault">
>        <xs:complexType>
>                <xs:sequence>
>                        <xs:element name="message" type="xs:string" />
>                </xs:sequence>
>        </xs:complexType>
> </xs:element>
>
> So I can send a message to client in the fault, also I change the
> services.xml file adding Faults to the respective methods.
>
> And now I compile service like I do before change WSDL and all is ok,
> but when I try to compile client, the client hasn't got the file of
> MyFault class, it has only MyFaultException class.
>
> My doubt is, do I have to copy manually the Fault class files? The
> WSDL2Java tool has an option to create Fault class files in client
> side, like it does in service side?
>
> Thanks a lot!
>
> --
> Saludos
>
> Fran
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Davanum Srinivas :: http://davanum.wordpress.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [AXIS2] Throwing exceptions with ADB

Posted by Davanum Srinivas <da...@gmail.com>.
Fran,

Did you try "-g" option in wsdl2java when generating the client?

thanks,
dims

On 6/5/07, Fran <fc...@gmail.com> wrote:
> Hi, list!
>
> I have a problem throwing Exceptions from service to client, using ADB.
>
> I create a service with Exceptions in some methods, I compile this
> class and I create WSDL with Java2WSDL tool. In this WSDL I change
> these lines:
>
> <xs:element name="MyFault">
>        <xs:complexType>
>                <xs:sequence>
>                        <xs:element name="message" type="xs:string" />
>                </xs:sequence>
>        </xs:complexType>
> </xs:element>
>
> So I can send a message to client in the fault, also I change the
> services.xml file adding Faults to the respective methods.
>
> And now I compile service like I do before change WSDL and all is ok,
> but when I try to compile client, the client hasn't got the file of
> MyFault class, it has only MyFaultException class.
>
> My doubt is, do I have to copy manually the Fault class files? The
> WSDL2Java tool has an option to create Fault class files in client
> side, like it does in service side?
>
> Thanks a lot!
>
> --
> Saludos
>
> Fran
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Davanum Srinivas :: http://davanum.wordpress.com

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org