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 ad...@dgi.finances.gouv.fr on 2004/01/22 11:48:55 UTC

How to send custom exception through SOAP message ?

Hello,


I'm using WebService with JBoss and Axis 1.0.
My EJBs throw RemoteException, as usual, but alse custom exceptions, 
extending java.lang.Exception.

This exception appears in the .wsdd file like this :

<wsdl:message name="RemoteFonctionnelException">
 <wsdl:part name="silo" type="xsd:int"/>
</wsdl:message>

Everything is working fine with system exception (seen as remoteException, 
so ...)


But, when my EJBs throw this kind of custom exception, I never get 
reference of this exception in soap envelope. I get a kind of 
myException.toString() message ...


Here is a response :


<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <SOAP-ENV:Fault>
   <faultcode 
xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.userException</faultcode>
 
<faultstring>fr.gouv.dgi.adelie.silocommun.RemoteFonctionnelException</faultstring>
   <detail>
    <ns2:stackTrace 
xmlns:ns2="http://xml.apache.org/axis/">fr.gouv.dgi.adelie.silocommun.RemoteFonctionnelException&#xd;

        <... SNIP STACKTRACE>

        </ns2:stackTrace>
   </detail>
  </SOAP-ENV:Fault>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


How can I unserialize this exception if the structure of the exception is 
not respected in the reponse ?


Thanks



Damien Lecan

Re: How to send custom exception through SOAP message ?

Posted by Peter Mount <pe...@retep.org.uk>.

On Thu, 22 Jan 2004, jerome moliere wrote:

> Hi damien,
> I guess that your custom exceptions may be child from remote exceptions
> because they must serialized....
> However I cannot encourage you to use such practices because you must not
> forget that SOAP messages could be used in environements where the
> exception concept doesn't exist....It's one from the design usage I
> suggest whend ealing with SOAP..Like avoid using your own serializers
> because they could be useless when used with a non Java target language...

I agree with you. Unless you can guarantee that the client is going to be
java & axis based, you shouldn't use your own serializer.

I have had to do this once for a client, but in that case the design
specification was that the client to the service was to be their own
application, and the serializer was needed for performance reasons (cut
the runtime down by 70%).

However, all the other services I've written use the default serializers
because they are public, and the client app could be any target language.

Peter

-- 
Peter Mount
peter@retep.org.uk
http://www.retep.org/
http://retep.net/
   Tel: +44 (0) 1622 749439
   Fax: +44 (0) 8701 361620
Mobile: +44 (0) 7838 191423
    IM-MSN: retep207@hotmail.com
IM-AOL/ICQ: retepworld



Re: How to send custom exception through SOAP message ?

Posted by jerome moliere <jm...@nerim.net>.
> Hello,
>
>
> I'm using WebService with JBoss and Axis 1.0.
> My EJBs throw RemoteException, as usual, but alse custom exceptions,
> extending java.lang.Exception.
>
> This exception appears in the .wsdd file like this :
>
> <wsdl:message name="RemoteFonctionnelException">
>  <wsdl:part name="silo" type="xsd:int"/>
> </wsdl:message>
>
> Everything is working fine with system exception (seen as remoteException,
> so ...)
>
>
> But, when my EJBs throw this kind of custom exception, I never get
> reference of this exception in soap envelope. I get a kind of
> myException.toString() message ...
>
>
> Here is a response :
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
>  <SOAP-ENV:Body>
>   <SOAP-ENV:Fault>
>    <faultcode
> xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.userException</faultcode>
>
> <faultstring>fr.gouv.dgi.adelie.silocommun.RemoteFonctionnelException</faultstring>
>    <detail>
>     <ns2:stackTrace
> xmlns:ns2="http://xml.apache.org/axis/">fr.gouv.dgi.adelie.silocommun.RemoteFonctionnelException
>
>         <... SNIP STACKTRACE>
>
>         </ns2:stackTrace>
>    </detail>
>   </SOAP-ENV:Fault>
>  </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
>
> How can I unserialize this exception if the structure of the exception is
> not respected in the reponse ?
>

Hi damien,
I guess that your custom exceptions may be child from remote exceptions
because they must serialized....
However I cannot encourage you to use such practices because you must not
forget that SOAP messages could be used in environements where the
exception concept doesn't exist....It's one from the design usage I
suggest whend ealing with SOAP..Like avoid using your own serializers
because they could be useless when used with a non Java target language...

HTH
-- 
Auteur cahier du programmeur Java tome 2 - Eyrolles 10/2003
http://www.eyrolles.com/php.informatique/Ouvrages/ouvrage.php3?ouv_ean13=9782212111941