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 George Jagodzinski <ge...@fusionapps.com> on 2003/06/24 21:22:11 UTC

RE: Exception handling strategy question

if you are refering to business logic that happens after the request has
been accepted I would say that the best way is to return some type of error
report. I could be wrong but it seems like soap fault should only be thrown
if there was a conformance issue. Someone please correct me if I am wrong.

--George

-----Original Message-----
From: remko de knikker [mailto:remko.deknikker@yale.edu]
Sent: Tuesday, June 24, 2003 3:22 PM
To: axis-user@ws.apache.org
Subject: Exception handling strategy question


when implementing a web service and a ws client, what is the general
design principle for exception handling, when
1. when user entered a non-valid input value, for instance it doesn't
exist in the database?
Do I simply through a SOAPFault or is it better to append my own
<doesnotexist> tag?

2. as a client, do I catch an xxxxException/Fault, do I look for the
soapenv:Fault tag or do I have to look the webservice specific <wserror>
tag??

What is the best design strategy here??

thanks,
r


Re: Exception handling strategy question

Posted by Anne Thomas Manes <an...@manes.net>.
Remko,

If you're working with the low-level API, then I guess you need to construct your SOAP fault manually (someone correct me if I'm wrong). A SOAP fault element must be the first and only child of the SOAP body element. You want to use addFault () to create a SOAPFault object and add it to the SOAPBody. Then you want to set the fault code and fault string and add the detail.

(This is using the SAAJ API).

Anne
  ----- Original Message ----- 
  From: remko de knikker 
  To: axis-user@ws.apache.org 
  Sent: Friday, June 27, 2003 2:29 PM
  Subject: Re: Exception handling strategy question


  Response:
  Anne, thanks for your response. The reason why I am returning a Document is because I need to return XML, this is just the way I defined/need to format my response(1). Because I must also be able to be invoked from all languages, I can't expect the clients to catch the Java Exceptions(2). 

  For these two reasons, I am trying to solve it by appending the mapped SOAPFault (created when the Exception was thrown) to the Document to be returned. 

  Question:
  But how to append the SOAPFault object with 'appendChild(Node f)' which takes a Node?
  I keep getting castExceptions when I try to cast the SOAPFault.

  or maybe I am on the wrong track here, and this isn't the way to do it?

  remko


  Anne Thomas Manes wrote:

    Remko,

    You don't have to return a Document in order to ensure language-neutrality. The whole point of SOAP and WSDL is to provide a layer of abstraction between your object model and your message structure that ensures language-neutrality. Axis lets you return whatever your application would like to return, and then Axis will convert that return into a document for you. No matter how you define your service (RPC or Document -- whether you marshal the message or you let Axis marshal the message), the client SOAP processing engine (e.g., .NET, MS SOAP, PocketSOAP, SOAP::Lite, Axis, etc) will receive a document, and that SOAP processing engine can automatically transform that document into the appropriate language objects on the client side (VB, C#, Java, Perl, etc).

    It's fine if you want your application to work directly with the XML -- the Axis Messaging style lets you do so -- but I want to make sure that you understand that you don't have to do so to ensure language-neutrality. 

    When you return a fault, you don't return a response message -- you return a fault message. Axis can automatically capture an exception and return that exception to the client in a fault message, but that doesn't help much if the client isn't Java. Therefore you need to define a fault message for each of your exceptions, and then tell Axis to map the exceptions to the faults accordingly.

    Anne

      ----- Original Message ----- 
      From: remko de knikker 
      To: axis-user@ws.apache.org 
      Sent: Friday, June 27, 2003 1:31 PM
      Subject: Re: Exception handling strategy question


      Situation:
      OK, so far this helped, and pointed out the right direction in which to go. I had seen the SOAP Faults and understand now when to use them.
      I use the document/literal or message style of web services in axis, since I am sending XML only.
      I use the 
      'public Document method(Document doc)' 
      signature, and I need to be language neutral, and therefor have to return a Document regardless. The Java Exceptions are indeed caught by the client, but I can't use this method.
      I managed to add a Fault to the SOAPBody object from the MessageContext and set its parameters, but as mentioned I need to return the Document, eg responseDoc, so the/any client can query this for Faults.... or do I have to deal with it differently??

      Question:
      How do I append the Fault object to the Document to be returned??






      Anne Thomas Manes wrote:

There are four defined reasons to return a SOAP fault [1]:
- VersionMismatch: the request didn't specify the correct SOAP namespace
- MustUnderstand: a SOAP node did not understand a SOAP header that said
mustUnderstand='1'
- Client: the request failed either because it was malformed or contained
invalid data
- Server: the request failed because of some type of server error

Remko's example requires an error code of Client. The error report should be
returned in the fault <details> element. As long as you have Java on both
sides of the wire, the SOAP system on the client should be able to simply
rethrow the original exception (assuming that it has the exception class
installed). But if you intend to support non-Java clients, you should map
your various exceptions to specific SOAP fault messages.

[1] http://www.w3.org/TR/SOAP/#_Toc478383510

Regards,
Anne

----- Original Message -----
From: "George Jagodzinski" <ge...@fusionapps.com>
To: <ax...@ws.apache.org>
Sent: Tuesday, June 24, 2003 3:22 PM
Subject: RE: Exception handling strategy question


  
if you are refering to business logic that happens after the request has
been accepted I would say that the best way is to return some type of
    
error
  
report. I could be wrong but it seems like soap fault should only be
    
thrown
  
if there was a conformance issue. Someone please correct me if I am wrong.

--George

-----Original Message-----
From: remko de knikker [mailto:remko.deknikker@yale.edu]
Sent: Tuesday, June 24, 2003 3:22 PM
To: axis-user@ws.apache.org
Subject: Exception handling strategy question


when implementing a web service and a ws client, what is the general
design principle for exception handling, when
1. when user entered a non-valid input value, for instance it doesn't
exist in the database?
Do I simply through a SOAPFault or is it better to append my own
<doesnotexist> tag?

2. as a client, do I catch an xxxxException/Fault, do I look for the
soapenv:Fault tag or do I have to look the webservice specific <wserror>
tag??

What is the best design strategy here??

thanks,
r

    


  





Re: Exception handling strategy question

Posted by remko de knikker <re...@yale.edu>.
Response:
Anne, thanks for your response. The reason why I am returning a Document 
is because I need to return XML, this is just the way I defined/need to 
format my response(1). Because I must also be able to be invoked from 
all languages, I can't expect the clients to catch the Java Exceptions(2).

For these two reasons, I am trying to solve it by appending the mapped 
SOAPFault (created when the Exception was thrown) to the Document to be 
returned.

Question:
But how to append the SOAPFault object with 'appendChild(Node f)' which 
takes a Node?
I keep getting castExceptions when I try to cast the SOAPFault.

or maybe I am on the wrong track here, and this isn't the way to do it?

remko


Anne Thomas Manes wrote:

> Remko,
>  
> You don't have to return a Document in order to ensure 
> language-neutrality. The whole point of SOAP and WSDL is to provide a 
> layer of abstraction between your object model and your message 
> structure that ensures language-neutrality. Axis lets you return 
> whatever your application would like to return, and then Axis will 
> convert that return into a document for you. No matter how you define 
> your service (RPC or Document -- whether you marshal the message or 
> you let Axis marshal the message), the client SOAP processing engine 
> (e.g., .NET, MS SOAP, PocketSOAP, SOAP::Lite, Axis, etc) will receive 
> a document, and that SOAP processing engine can automatically 
> transform that document into the appropriate language objects on the 
> client side (VB, C#, Java, Perl, etc).
>  
> It's fine if you want your application to work directly with the XML 
> -- the Axis Messaging style lets you do so -- but I want to make sure 
> that you understand that you don't have to do so to ensure 
> language-neutrality.
>  
> When you return a fault, you don't return a response message -- you 
> return a fault message. Axis can automatically capture an exception 
> and return that exception to the client in a fault message, but that 
> doesn't help much if the client isn't Java. Therefore you need to 
> define a fault message for each of your exceptions, and then tell Axis 
> to map the exceptions to the faults accordingly.
>  
> Anne
>  
>
>     ----- Original Message -----
>     From: remko de knikker <ma...@yale.edu>
>     To: axis-user@ws.apache.org <ma...@ws.apache.org>
>     Sent: Friday, June 27, 2003 1:31 PM
>     Subject: Re: Exception handling strategy question
>
>     Situation:
>     OK, so far this helped, and pointed out the right direction in
>     which to go. I had seen the SOAP Faults and understand now when to
>     use them.
>     I use the document/literal or message style of web services in
>     axis, since I am sending XML only.
>     I use the
>     'public Document method(Document doc)'
>     signature, and I need to be language neutral, and therefor have to
>     return a Document regardless. The Java Exceptions are indeed
>     caught by the client, but I can't use this method.
>     I managed to add a Fault to the SOAPBody object from the
>     MessageContext and set its parameters, but as mentioned I need to
>     return the Document, eg responseDoc, so the/any client can query
>     this for Faults.... or do I have to deal with it differently??
>
>     Question:
>     How do I append the Fault object to the Document to be returned??
>
>
>
>
>
>
>     Anne Thomas Manes wrote:
>
>>There are four defined reasons to return a SOAP fault [1]:
>>- VersionMismatch: the request didn't specify the correct SOAP namespace
>>- MustUnderstand: a SOAP node did not understand a SOAP header that said
>>mustUnderstand='1'
>>- Client: the request failed either because it was malformed or contained
>>invalid data
>>- Server: the request failed because of some type of server error
>>
>>Remko's example requires an error code of Client. The error report should be
>>returned in the fault <details> element. As long as you have Java on both
>>sides of the wire, the SOAP system on the client should be able to simply
>>rethrow the original exception (assuming that it has the exception class
>>installed). But if you intend to support non-Java clients, you should map
>>your various exceptions to specific SOAP fault messages.
>>
>>[1] http://www.w3.org/TR/SOAP/#_Toc478383510
>>
>>Regards,
>>Anne
>>
>>----- Original Message -----
>>From: "George Jagodzinski" <ge...@fusionapps.com>
>>To: <ax...@ws.apache.org>
>>Sent: Tuesday, June 24, 2003 3:22 PM
>>Subject: RE: Exception handling strategy question
>>
>>
>>  
>>
>>>if you are refering to business logic that happens after the request has
>>>been accepted I would say that the best way is to return some type of
>>>    
>>>
>>error
>>  
>>
>>>report. I could be wrong but it seems like soap fault should only be
>>>    
>>>
>>thrown
>>  
>>
>>>if there was a conformance issue. Someone please correct me if I am wrong.
>>>
>>>--George
>>>
>>>-----Original Message-----
>>>From: remko de knikker [mailto:remko.deknikker@yale.edu]
>>>Sent: Tuesday, June 24, 2003 3:22 PM
>>>To: axis-user@ws.apache.org
>>>Subject: Exception handling strategy question
>>>
>>>
>>>when implementing a web service and a ws client, what is the general
>>>design principle for exception handling, when
>>>1. when user entered a non-valid input value, for instance it doesn't
>>>exist in the database?
>>>Do I simply through a SOAPFault or is it better to append my own
>>><doesnotexist> tag?
>>>
>>>2. as a client, do I catch an xxxxException/Fault, do I look for the
>>>soapenv:Fault tag or do I have to look the webservice specific <wserror>
>>>tag??
>>>
>>>What is the best design strategy here??
>>>
>>>thanks,
>>>r
>>>
>>>    
>>>
>>
>>
>>  
>>
>


Re: Exception handling strategy question

Posted by Anne Thomas Manes <an...@manes.net>.
You don't *need* to define the SOAP faults, but you *should* do so if you want to ba able to support non-Java clients. If you don't define the faults, Axis will simply return the Java exception, and a VB.NET client has no idea what to do with a Java exception.

You define the SOAP fault <detail> information as a message <part>. A fault message is always formating using the document style. 

Anne 
  ----- Original Message ----- 
  From: remko de knikker 
  To: axis-user@ws.apache.org 
  Sent: Monday, June 30, 2003 4:48 PM
  Subject: Re: Exception handling strategy question


  I am not a 100% sure, but as far as I understand it now, you don't need to specify the SOAP Faults in your xsd, these are SOAP specific, not part of your response message.

  r

  Tony Opatha wrote:

    >Therefore you need to define a fault message for each of your exceptions, and then tell >Axis to map the exceptions to the faults accordingly.

    So, this means that AXIS supports application-specific Faults for both document-style
    and RPC-style so long as the .xsd schema for the custom Fault messages is specificied
    as part of the WSDL, right?

    thanks,
    Tony






    Anne Thomas Manes <an...@manes.net> wrote:
      Remko,

      You don't have to return a Document in order to ensure language-neutrality. The whole point of SOAP and WSDL is to provide a layer of abstraction between your object model and your message structure that ensures language-neutrality. Axis lets you return whatever your application would like to return, and then Axis will convert that return into a document for you. No matter how you define your service (RPC or Document -- whether you marshal the message or you let Axis marshal the message), the client SOAP processing engine (e.g., .NET, MS SOAP, PocketSOAP, SOAP::Lite, Axis, etc) will receive a document, and that SOAP processing engine can automatically transform that document into the appropriate language objects on the client side (VB, C#, Java, Perl, etc).

      It's fine if you want your application to work directly with the XML -- the Axis Messaging style lets you do so -- but I want to make sure that you understand that you don't have to do so to ensure language-neutrality. 

      When you return a fault, you don't return a response message -- you return a fault message. Axis can automatically capture an exception and return that exception to the client in a fault message, but that doesn't help much if the client isn't Java. Therefore you need to define a fault message for each of your exceptions, and then tell Axis to map the exceptions to the faults accordingly.

      Anne

        ----- Original Message ----- 
        From: remko de knikker 
        To: axis-user@ws.apache.org 
        Sent: Friday, June 27, 2003 1:31 PM
        Subject: Re: Exception handling strategy question


        Situation:
        OK, so far this helped, and pointed out the right direction in which to go. I had seen the SOAP Faults and understand now when to use them.
        I use the document/literal or message style of web services in axis, since I am sending XML only.
        I use the 
        'public Document method(Document doc)' 
        signature, and I need to be language neutral, and therefor have to return a Document regardless. The Java Exceptions are indeed caught by the client, but I can't use this method.
        I managed to add a Fault to the SOAPBody object from the MessageContext and set its parameters, but as mentioned I need to return the Document, eg responseDoc, so the/any client can query this for Faults.... or do I have to deal with it differently??

        Question:
        How do I append the Fault object to the Document to be returned??






        Anne Thomas Manes wrote:

There are four defined reasons to return a SOAP fault [1]:
- VersionMismatch: the request didn't specify the correct SOAP namespace
- MustUnderstand: a SOAP node did not understand a SOAP header that said
mustUnderstand='1'
- Client: the request failed either because it was malformed or contained
invalid data
- Server: the request failed because of some type of server error

Remko's example requires an error code of Client. The error report should be
returned in the fault <details> element. As long as you have Java on both
sides of the wire, the SOAP system on the client should be able to simply
rethrow the original exception (assuming that it has the exception class
installed). But if you intend to support non-Java clients, you should map
your various exceptions to specific SOAP fault messages.

[1] http://www.w3.org/TR/SOAP/#_Toc478383510

Regards,
Anne

----- Original Message -----
From: "George Jagodzinski" <ge...@fusionapps.com>
To: <ax...@ws.apache.org>
Sent: Tuesday, June 24, 2003 3:22 PM
Subject: RE: Exception handling strategy question


  
if you are refering to business logic that happens after the request has
been accepted I would say that the best way is to return some type of
    
error
  
report. I could be wrong but it seems like soap fault should only be
    
thrown
  
if there was a conformance issue. Someone please correct me if I am wrong.

--George

-----Original Message-----
From: remko de knikker [mailto:remko.deknikker@yale.edu]
Sent: Tuesday, June 24, 2003 3:22 PM
To: axis-user@ws.apache.org
Subject: Exception handling strategy question


when implementing a web service and a ws client, what is the general
design principle for exception handling, when
1. when user entered a non-valid input value, for instance it doesn't
exist in the database?
Do I simply through a SOAPFault or is it better to append my own
<doesnotexist> tag?

2. as a client, do I catch an xxxxException/Fault, do I look for the
soapenv:Fault tag or do I have to look the webservice specific <wserror>
tag??

What is the best design strategy here??

thanks,
r

    


  


----------------------------------------------------------------------------
    Do you Yahoo!?
    SBC Yahoo! DSL - Now only $29.95 per month! 



Re: Exception handling strategy question

Posted by remko de knikker <re...@yale.edu>.
I am not a 100% sure, but as far as I understand it now, you don't need 
to specify the SOAP Faults in your xsd, these are SOAP specific, not 
part of your response message.

r

Tony Opatha wrote:

> >Therefore you need to define a fault message for each of your 
> exceptions, and then tell >Axis to map the exceptions to the faults 
> accordingly.
>  
> So, this means that AXIS supports application-specific Faults for both 
> document-style
> and RPC-style so long as the .xsd schema for the custom Fault messages 
> is specificied
> as part of the WSDL, right?
>  
> thanks,
> Tony
>  
>  
>  
>  
>
>
> Anne Thomas Manes <an...@manes.net> wrote:
>
>     Remko,
>      
>     You don't have to return a Document in order to ensure
>     language-neutrality. The whole point of SOAP and WSDL is to
>     provide a layer of abstraction between your object model and your
>     message structure that ensures language-neutrality. Axis lets you
>     return whatever your application would like to return, and then
>     Axis will convert that return into a document for you. No matter
>     how you define your service (RPC or Document -- whether you
>     marshal the message or you let Axis marshal the message), the
>     client SOAP processing engine (e.g., .NET, MS SOAP, PocketSOAP,
>     SOAP::Lite, Axis, etc) will receive a document, and that SOAP
>     processing engine can automatically transform that document into
>     the appropriate language objects on the client side (VB, C#, Java,
>     Perl, etc).
>      
>     It's fine if you want your application to work directly with the
>     XML -- the Axis Messaging style lets you do so -- but I want to
>     make sure that you understand that you don't have to do so to
>     ensure language-neutrality.
>      
>     When you return a fault, you don't return a response message --
>     you return a fault message. Axis can automatically capture an
>     exception and return that exception to the client in a fault
>     message, but that doesn't help much if the client isn't Java.
>     Therefore you need to define a fault message for each of your
>     exceptions, and then tell Axis to map the exceptions to the faults
>     accordingly.
>      
>     Anne
>      
>
>         ----- Original Message -----
>         From: remko de knikker <ma...@yale.edu>
>         To: axis-user@ws.apache.org <ma...@ws.apache.org>
>         Sent: Friday, June 27, 2003 1:31 PM
>         Subject: Re: Exception handling strategy question
>
>         Situation:
>         OK, so far this helped, and pointed out the right direction in
>         which to go. I had seen the SOAP Faults and understand now
>         when to use them.
>         I use the document/literal or message style of web services in
>         axis, since I am sending XML only.
>         I use the
>         'public Document method(Document doc)'
>         signature, and I need to be language neutral, and therefor
>         have to return a Document regardless. The Java Exceptions are
>         indeed caught by the client, but I can't use this method.
>         I managed to add a Fault to the SOAPBody object from the
>         MessageContext and set its parameters, but as mentioned I need
>         to return the Document, eg responseDoc, so the/any client can
>         query this for Faults.... or do I have to deal with it
>         differently??
>
>         Question:
>         How do I append the Fault object to the Document to be returned??
>
>
>
>
>
>
>         Anne Thomas Manes wrote:
>
>>There are four defined reasons to return a SOAP fault [1]:
>>- VersionMismatch: the request didn't specify the correct SOAP namespace
>>- MustUnderstand: a SOAP node did not understand a SOAP header that said
>>mustUnderstand='1'
>>- Client: the request failed either because it was malformed or contained
>>invalid data
>>- Server: the request failed because of some type of server error
>>
>>Remko's example requires an error code of Client. The error report should be
>>returned in the fault <details> element. As long as you have Java on both
>>sides of the wire, the SOAP system on the client should be able to simply
>>rethrow the original exception (assuming that it has the exception class
>>installed). But if you intend to support non-Java clients, you should map
>>your various exceptions to specific SOAP fault messages.
>>
>>[1] http://www.w3.org/TR/SOAP/#_Toc478383510
>>
>>Regards,
>>Anne
>>
>>----- Original Message -----
>>From: "George Jagodzinski" <ge...@fusionapps.com>
>>To: <ax...@ws.apache.org>
>>Sent: Tuesday, June 24, 2003 3:22 PM
>>Subject: RE: Exception handling strategy question
>>
>>
>>  
>>
>>>if you are refering to business logic that happens after the request has
>>>been accepted I would say that the best way is to return some type of
>>>    
>>>
>>error
>>  
>>
>>>report. I could be wrong but it seems like soap fault should only be
>>>    
>>>
>>thrown
>>  
>>
>>>if there was a conformance issue. Someone please correct me if I am wrong.
>>>
>>>--George
>>>
>>>-----Original Message-----
>>>From: remko de knikker [mailto:remko.deknikker@yale.edu]
>>>Sent: Tuesday, June 24, 2003 3:22 PM
>>>To: axis-user@ws.apache.org
>>>Subject: Exception handling strategy question
>>>
>>>
>>>when implementing a web service and a ws client, what is the general
>>>design principle for exception handling, when
>>>1. when user entered a non-valid input value, for instance it doesn't
>>>exist in the database?
>>>Do I simply through a SOAPFault or is it better to append my own
>>><doesnotexist> tag?
>>>
>>>2. as a client, do I catch an xxxxException/Fault, do I look for the
>>>soapenv:Fault tag or do I have to look the webservice specific <wserror>
>>>tag??
>>>
>>>What is the best design strategy here??
>>>
>>>thanks,
>>>r
>>>
>>>    
>>>
>>
>>
>>  
>>
>
> ------------------------------------------------------------------------
> Do you Yahoo!?
> SBC Yahoo! DSL 
> <http://pa.yahoo.com/*http://rd.yahoo.com/evt=1207/*http://promo.yahoo.com/sbc/> 
> - Now only $29.95 per month! 



Re: Exception handling strategy question

Posted by Tony Opatha <to...@yahoo.com>.
>Therefore you need to define a fault message for each of your exceptions, and then tell >Axis to map the exceptions to the faults accordingly.
 
So, this means that AXIS supports application-specific Faults for both document-style
and RPC-style so long as the .xsd schema for the custom Fault messages is specificied
as part of the WSDL, right?
 
thanks,
Tony
 
 
 
 


Anne Thomas Manes <an...@manes.net> wrote:
Remko,
 
You don't have to return a Document in order to ensure language-neutrality. The whole point of SOAP and WSDL is to provide a layer of abstraction between your object model and your message structure that ensures language-neutrality. Axis lets you return whatever your application would like to return, and then Axis will convert that return into a document for you. No matter how you define your service (RPC or Document -- whether you marshal the message or you let Axis marshal the message), the client SOAP processing engine (e.g., .NET, MS SOAP, PocketSOAP, SOAP::Lite, Axis, etc) will receive a document, and that SOAP processing engine can automatically transform that document into the appropriate language objects on the client side (VB, C#, Java, Perl, etc).
 
It's fine if you want your application to work directly with the XML -- the Axis Messaging style lets you do so -- but I want to make sure that you understand that you don't have to do so to ensure language-neutrality. 
 
When you return a fault, you don't return a response message -- you return a fault message. Axis can automatically capture an exception and return that exception to the client in a fault message, but that doesn't help much if the client isn't Java. Therefore you need to define a fault message for each of your exceptions, and then tell Axis to map the exceptions to the faults accordingly.
 
Anne
 
----- Original Message ----- 
From: remko de knikker 
To: axis-user@ws.apache.org 
Sent: Friday, June 27, 2003 1:31 PM
Subject: Re: Exception handling strategy question


Situation:
OK, so far this helped, and pointed out the right direction in which to go. I had seen the SOAP Faults and understand now when to use them.
I use the document/literal or message style of web services in axis, since I am sending XML only.
I use the 
'public Document method(Document doc)' 
signature, and I need to be language neutral, and therefor have to return a Document regardless. The Java Exceptions are indeed caught by the client, but I can't use this method.
I managed to add a Fault to the SOAPBody object from the MessageContext and set its parameters, but as mentioned I need to return the Document, eg responseDoc, so the/any client can query this for Faults.... or do I have to deal with it differently??

Question:
How do I append the Fault object to the Document to be returned??






Anne Thomas Manes wrote:

There are four defined reasons to return a SOAP fault [1]:- VersionMismatch: the request didn't specify the correct SOAP namespace- MustUnderstand: a SOAP node did not understand a SOAP header that saidmustUnderstand='1'- Client: the request failed either because it was malformed or containedinvalid data- Server: the request failed because of some type of server errorRemko's example requires an error code of Client. The error report should bereturned in the fault <details> element. As long as you have Java on bothsides of the wire, the SOAP system on the client should be able to simplyrethrow the original exception (assuming that it has the exception classinstalled). But if you intend to support non-Java clients, you should mapyour various exceptions to specific SOAP fault messages.[1] http://www.w3.org/TR/SOAP/#_Toc478383510Regards,Anne----- Original Message -----From: "George Jagodzinski" <ge...@fusionapps.com>To: <ax...@ws.apache.org>Sent: Tuesday, June 24, 2003 3:22
 PMSubject: RE: Exception handling strategy question  

if you are refering to business logic that happens after the request hasbeen accepted I would say that the best way is to return some type of    

error  

report. I could be wrong but it seems like soap fault should only be    

thrown  

if there was a conformance issue. Someone please correct me if I am wrong.--George-----Original Message-----From: remko de knikker [mailto:remko.deknikker@yale.edu]Sent: Tuesday, June 24, 2003 3:22 PMTo: axis-user@ws.apache.orgSubject: Exception handling strategy questionwhen implementing a web service and a ws client, what is the generaldesign principle for exception handling, when1. when user entered a non-valid input value, for instance it doesn'texist in the database?Do I simply through a SOAPFault or is it better to append my own<doesnotexist> tag?2. as a client, do I catch an xxxxException/Fault, do I look for thesoapenv:Fault tag or do I have to look the webservice specific <wserror>tag??What is the best design strategy here??thanks,r    

  





---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: Exception handling strategy question

Posted by Tony Opatha <to...@yahoo.com>.
>Therefore you need to define a fault message for each of your exceptions, and then tell >Axis to map the exceptions to the faults accordingly.
 
So, this means that AXIS supports application-specific Faults for both document-style
and RPC-style so long as the .xsd schema for the custom Fault messages is specificied
as part of the WSDL, right?
 
thanks,
Tony
 
 
 
 


Anne Thomas Manes <an...@manes.net> wrote:
Remko,
 
You don't have to return a Document in order to ensure language-neutrality. The whole point of SOAP and WSDL is to provide a layer of abstraction between your object model and your message structure that ensures language-neutrality. Axis lets you return whatever your application would like to return, and then Axis will convert that return into a document for you. No matter how you define your service (RPC or Document -- whether you marshal the message or you let Axis marshal the message), the client SOAP processing engine (e.g., .NET, MS SOAP, PocketSOAP, SOAP::Lite, Axis, etc) will receive a document, and that SOAP processing engine can automatically transform that document into the appropriate language objects on the client side (VB, C#, Java, Perl, etc).
 
It's fine if you want your application to work directly with the XML -- the Axis Messaging style lets you do so -- but I want to make sure that you understand that you don't have to do so to ensure language-neutrality. 
 
When you return a fault, you don't return a response message -- you return a fault message. Axis can automatically capture an exception and return that exception to the client in a fault message, but that doesn't help much if the client isn't Java. Therefore you need to define a fault message for each of your exceptions, and then tell Axis to map the exceptions to the faults accordingly.
 
Anne
 
----- Original Message ----- 
From: remko de knikker 
To: axis-user@ws.apache.org 
Sent: Friday, June 27, 2003 1:31 PM
Subject: Re: Exception handling strategy question


Situation:
OK, so far this helped, and pointed out the right direction in which to go. I had seen the SOAP Faults and understand now when to use them.
I use the document/literal or message style of web services in axis, since I am sending XML only.
I use the 
'public Document method(Document doc)' 
signature, and I need to be language neutral, and therefor have to return a Document regardless. The Java Exceptions are indeed caught by the client, but I can't use this method.
I managed to add a Fault to the SOAPBody object from the MessageContext and set its parameters, but as mentioned I need to return the Document, eg responseDoc, so the/any client can query this for Faults.... or do I have to deal with it differently??

Question:
How do I append the Fault object to the Document to be returned??






Anne Thomas Manes wrote:

There are four defined reasons to return a SOAP fault [1]:- VersionMismatch: the request didn't specify the correct SOAP namespace- MustUnderstand: a SOAP node did not understand a SOAP header that saidmustUnderstand='1'- Client: the request failed either because it was malformed or containedinvalid data- Server: the request failed because of some type of server errorRemko's example requires an error code of Client. The error report should bereturned in the fault <details> element. As long as you have Java on bothsides of the wire, the SOAP system on the client should be able to simplyrethrow the original exception (assuming that it has the exception classinstalled). But if you intend to support non-Java clients, you should mapyour various exceptions to specific SOAP fault messages.[1] http://www.w3.org/TR/SOAP/#_Toc478383510Regards,Anne----- Original Message -----From: "George Jagodzinski" <ge...@fusionapps.com>To: <ax...@ws.apache.org>Sent: Tuesday, June 24, 2003 3:22
 PMSubject: RE: Exception handling strategy question  

if you are refering to business logic that happens after the request hasbeen accepted I would say that the best way is to return some type of    

error  

report. I could be wrong but it seems like soap fault should only be    

thrown  

if there was a conformance issue. Someone please correct me if I am wrong.--George-----Original Message-----From: remko de knikker [mailto:remko.deknikker@yale.edu]Sent: Tuesday, June 24, 2003 3:22 PMTo: axis-user@ws.apache.orgSubject: Exception handling strategy questionwhen implementing a web service and a ws client, what is the generaldesign principle for exception handling, when1. when user entered a non-valid input value, for instance it doesn'texist in the database?Do I simply through a SOAPFault or is it better to append my own<doesnotexist> tag?2. as a client, do I catch an xxxxException/Fault, do I look for thesoapenv:Fault tag or do I have to look the webservice specific <wserror>tag??What is the best design strategy here??thanks,r    

  




---------------------------------
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: Exception handling strategy question

Posted by Anne Thomas Manes <an...@manes.net>.
Remko,

You don't have to return a Document in order to ensure language-neutrality. The whole point of SOAP and WSDL is to provide a layer of abstraction between your object model and your message structure that ensures language-neutrality. Axis lets you return whatever your application would like to return, and then Axis will convert that return into a document for you. No matter how you define your service (RPC or Document -- whether you marshal the message or you let Axis marshal the message), the client SOAP processing engine (e.g., .NET, MS SOAP, PocketSOAP, SOAP::Lite, Axis, etc) will receive a document, and that SOAP processing engine can automatically transform that document into the appropriate language objects on the client side (VB, C#, Java, Perl, etc).

It's fine if you want your application to work directly with the XML -- the Axis Messaging style lets you do so -- but I want to make sure that you understand that you don't have to do so to ensure language-neutrality. 

When you return a fault, you don't return a response message -- you return a fault message. Axis can automatically capture an exception and return that exception to the client in a fault message, but that doesn't help much if the client isn't Java. Therefore you need to define a fault message for each of your exceptions, and then tell Axis to map the exceptions to the faults accordingly.

Anne

  ----- Original Message ----- 
  From: remko de knikker 
  To: axis-user@ws.apache.org 
  Sent: Friday, June 27, 2003 1:31 PM
  Subject: Re: Exception handling strategy question


  Situation:
  OK, so far this helped, and pointed out the right direction in which to go. I had seen the SOAP Faults and understand now when to use them.
  I use the document/literal or message style of web services in axis, since I am sending XML only.
  I use the 
  'public Document method(Document doc)' 
  signature, and I need to be language neutral, and therefor have to return a Document regardless. The Java Exceptions are indeed caught by the client, but I can't use this method.
  I managed to add a Fault to the SOAPBody object from the MessageContext and set its parameters, but as mentioned I need to return the Document, eg responseDoc, so the/any client can query this for Faults.... or do I have to deal with it differently??

  Question:
  How do I append the Fault object to the Document to be returned??






  Anne Thomas Manes wrote:

There are four defined reasons to return a SOAP fault [1]:
- VersionMismatch: the request didn't specify the correct SOAP namespace
- MustUnderstand: a SOAP node did not understand a SOAP header that said
mustUnderstand='1'
- Client: the request failed either because it was malformed or contained
invalid data
- Server: the request failed because of some type of server error

Remko's example requires an error code of Client. The error report should be
returned in the fault <details> element. As long as you have Java on both
sides of the wire, the SOAP system on the client should be able to simply
rethrow the original exception (assuming that it has the exception class
installed). But if you intend to support non-Java clients, you should map
your various exceptions to specific SOAP fault messages.

[1] http://www.w3.org/TR/SOAP/#_Toc478383510

Regards,
Anne

----- Original Message -----
From: "George Jagodzinski" <ge...@fusionapps.com>
To: <ax...@ws.apache.org>
Sent: Tuesday, June 24, 2003 3:22 PM
Subject: RE: Exception handling strategy question


  
if you are refering to business logic that happens after the request has
been accepted I would say that the best way is to return some type of
    
error
  
report. I could be wrong but it seems like soap fault should only be
    
thrown
  
if there was a conformance issue. Someone please correct me if I am wrong.

--George

-----Original Message-----
From: remko de knikker [mailto:remko.deknikker@yale.edu]
Sent: Tuesday, June 24, 2003 3:22 PM
To: axis-user@ws.apache.org
Subject: Exception handling strategy question


when implementing a web service and a ws client, what is the general
design principle for exception handling, when
1. when user entered a non-valid input value, for instance it doesn't
exist in the database?
Do I simply through a SOAPFault or is it better to append my own
<doesnotexist> tag?

2. as a client, do I catch an xxxxException/Fault, do I look for the
soapenv:Fault tag or do I have to look the webservice specific <wserror>
tag??

What is the best design strategy here??

thanks,
r

    


  



Re: Exception handling strategy question

Posted by remko de knikker <re...@yale.edu>.
Situation:
OK, so far this helped, and pointed out the right direction in which to 
go. I had seen the SOAP Faults and understand now when to use them.
I use the document/literal or message style of web services in axis, 
since I am sending XML only.
I use the
'public Document method(Document doc)'
signature, and I need to be language neutral, and therefor have to 
return a Document regardless. The Java Exceptions are indeed caught by 
the client, but I can't use this method.
I managed to add a Fault to the SOAPBody object from the MessageContext 
and set its parameters, but as mentioned I need to return the Document, 
eg responseDoc, so the/any client can query this for Faults.... or do I 
have to deal with it differently??

Question:
How do I append the Fault object to the Document to be returned??






Anne Thomas Manes wrote:

>There are four defined reasons to return a SOAP fault [1]:
>- VersionMismatch: the request didn't specify the correct SOAP namespace
>- MustUnderstand: a SOAP node did not understand a SOAP header that said
>mustUnderstand='1'
>- Client: the request failed either because it was malformed or contained
>invalid data
>- Server: the request failed because of some type of server error
>
>Remko's example requires an error code of Client. The error report should be
>returned in the fault <details> element. As long as you have Java on both
>sides of the wire, the SOAP system on the client should be able to simply
>rethrow the original exception (assuming that it has the exception class
>installed). But if you intend to support non-Java clients, you should map
>your various exceptions to specific SOAP fault messages.
>
>[1] http://www.w3.org/TR/SOAP/#_Toc478383510
>
>Regards,
>Anne
>
>----- Original Message -----
>From: "George Jagodzinski" <ge...@fusionapps.com>
>To: <ax...@ws.apache.org>
>Sent: Tuesday, June 24, 2003 3:22 PM
>Subject: RE: Exception handling strategy question
>
>
>  
>
>>if you are refering to business logic that happens after the request has
>>been accepted I would say that the best way is to return some type of
>>    
>>
>error
>  
>
>>report. I could be wrong but it seems like soap fault should only be
>>    
>>
>thrown
>  
>
>>if there was a conformance issue. Someone please correct me if I am wrong.
>>
>>--George
>>
>>-----Original Message-----
>>From: remko de knikker [mailto:remko.deknikker@yale.edu]
>>Sent: Tuesday, June 24, 2003 3:22 PM
>>To: axis-user@ws.apache.org
>>Subject: Exception handling strategy question
>>
>>
>>when implementing a web service and a ws client, what is the general
>>design principle for exception handling, when
>>1. when user entered a non-valid input value, for instance it doesn't
>>exist in the database?
>>Do I simply through a SOAPFault or is it better to append my own
>><doesnotexist> tag?
>>
>>2. as a client, do I catch an xxxxException/Fault, do I look for the
>>soapenv:Fault tag or do I have to look the webservice specific <wserror>
>>tag??
>>
>>What is the best design strategy here??
>>
>>thanks,
>>r
>>
>>    
>>
>
>
>  
>


RE: Exception handling strategy question

Posted by George Jagodzinski <ge...@fusionapps.com>.
oh....so thats why they keep writing all of these standards. I guess I
actually have to read them.

Thanks

-----Original Message-----
From: Anne Thomas Manes [mailto:anne@manes.net]
Sent: Tuesday, June 24, 2003 3:53 PM
To: axis-user@ws.apache.org; george@fusionapps.com
Subject: Re: Exception handling strategy question


There are four defined reasons to return a SOAP fault [1]:
- VersionMismatch: the request didn't specify the correct SOAP namespace
- MustUnderstand: a SOAP node did not understand a SOAP header that said
mustUnderstand='1'
- Client: the request failed either because it was malformed or contained
invalid data
- Server: the request failed because of some type of server error

Remko's example requires an error code of Client. The error report should be
returned in the fault <details> element. As long as you have Java on both
sides of the wire, the SOAP system on the client should be able to simply
rethrow the original exception (assuming that it has the exception class
installed). But if you intend to support non-Java clients, you should map
your various exceptions to specific SOAP fault messages.

[1] http://www.w3.org/TR/SOAP/#_Toc478383510

Regards,
Anne


Re: Exception handling strategy question

Posted by Anne Thomas Manes <an...@manes.net>.
There are four defined reasons to return a SOAP fault [1]:
- VersionMismatch: the request didn't specify the correct SOAP namespace
- MustUnderstand: a SOAP node did not understand a SOAP header that said
mustUnderstand='1'
- Client: the request failed either because it was malformed or contained
invalid data
- Server: the request failed because of some type of server error

Remko's example requires an error code of Client. The error report should be
returned in the fault <details> element. As long as you have Java on both
sides of the wire, the SOAP system on the client should be able to simply
rethrow the original exception (assuming that it has the exception class
installed). But if you intend to support non-Java clients, you should map
your various exceptions to specific SOAP fault messages.

[1] http://www.w3.org/TR/SOAP/#_Toc478383510

Regards,
Anne

----- Original Message -----
From: "George Jagodzinski" <ge...@fusionapps.com>
To: <ax...@ws.apache.org>
Sent: Tuesday, June 24, 2003 3:22 PM
Subject: RE: Exception handling strategy question


> if you are refering to business logic that happens after the request has
> been accepted I would say that the best way is to return some type of
error
> report. I could be wrong but it seems like soap fault should only be
thrown
> if there was a conformance issue. Someone please correct me if I am wrong.
>
> --George
>
> -----Original Message-----
> From: remko de knikker [mailto:remko.deknikker@yale.edu]
> Sent: Tuesday, June 24, 2003 3:22 PM
> To: axis-user@ws.apache.org
> Subject: Exception handling strategy question
>
>
> when implementing a web service and a ws client, what is the general
> design principle for exception handling, when
> 1. when user entered a non-valid input value, for instance it doesn't
> exist in the database?
> Do I simply through a SOAPFault or is it better to append my own
> <doesnotexist> tag?
>
> 2. as a client, do I catch an xxxxException/Fault, do I look for the
> soapenv:Fault tag or do I have to look the webservice specific <wserror>
> tag??
>
> What is the best design strategy here??
>
> thanks,
> r
>