Hi Alek,
Thanks for your response. Yes i feel there needs to have a way as how to handle the faults for the WS irrespective of PHP, C#, JAVA.

Regards
-Sambit

On Mar 19, 2007, at 8:27 PM, Aleksander Slominski wrote:

sambit kumar dikshit wrote:
Hi Alek,
   I'm facing problems while trying to get the exceptions thrown from
the Service as fault. For example i have a class called TestService
which has a method test(String param1,String param2) and it throws an
exception called TestException.


   public Class TestService{

   public String test(String param1, String param2) throws
TestException {

        if(something wrong)

           {
               TestException ex = new TestException();
               ex.setErrorCode("test001");
              ex.setErrorMessage("Exception at test method line 12");

           }

    }
}



public Class TestException extends Exception implements Serializable {


private String errorCode;
private String errorMessage;

getter and setter methods for the above goes below......

}


Now the TestService class is exposed as a web service using Axis. The
fault message part for this comes as expected in wsdl file.

I'm using WSIF Apache Axis to invoke the service from the client. I
want to get a handle of the Fault i.e TestException class so that i
can get the details of the error code and error message.
Unfortunately i'm not able to get this at all. When i looked into the
code, i checked that it always checks for the AXIS Fault and takes the first element of the Axis Fault detail objects and set that Element to
WSIFMessage faultParts. I'm wondering dont we need to desrialize this
Element to the appropriate Exception Class like we do for the SOAP
Response Message.  Is there any specific reason we are not doing like
this.
i think it depends on AXIS - WSIF just uses what is out there and it is
provider that makes those decisions.
Also i think there is a problem with the way Axis handles the fault. I think it expects the exception to be a sub class of RemoteException.
Then this limits the interoporability.

Please suggest how to overcome this type of issues. My requirement is
to get the Exceptyion thrown from the Service back to the client and
client needs to introspect the exception like a normal response
message and get the appropriate error code, message out of it.
i do not think there is one perfect solution to this :-( quite often
faults that are sent by SOAP stack (not just AXIS - you shoul dnot
depend on other side to be in Java even) they are *not* declared in WSDL and you can not count that you can deserialize some SOAP Fault into some particular Java exception - what if Fault was generated by Python or C#?

in short i think this is for discussion and definitely one thing to
improve ...

best,

alek


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to