Throwing Exceptions from Server to Client
Is it possible to throw (Error.pm-style) exceptions on the
server-side, and catch these on the client-side? And how ;)?
Moreover, if possible, will such Exceptions thrown on a SOAP::Lite
server-side be possible to be caught by non-SOAP::Lite clients?
- On Thu, Mar 24, 2005 at 06:27:38PM -0000, Sebastien Boving & Nicole Kersting scratched on the wall:
> Is it possible to throw (Error.pm-style) exceptions on theSort of. SOAP has the concept of a "Fault" that indicates a
> server-side, and catch these on the client-side? And how ;)?
operational error. Actually, you can use them for anything, but
they're usually used to indicate an operational error (e.g. "cannot
connect to database") rather than a functional one (e.g. "no rows to
return"). There are some broad categories (like "Client" fault, e.g.
illegal function name, or "Server", e.g. Database down), but you can
extend the code to indicating a more specific error, e.g.
"Server.Database.CannotConect". You can also provide a
human-readable string. See SOAP::Fault for specifics.
You send one of these using "die" in any function handler:
if( $err )
-> faultcode( $SOAP::Constants::FAULT_CLIENT . 'AuthAuth' )
-> faultstring( 'Auth/Auth info is invalid.' );
Since all handlers are run under an exec( ), this acts like a thrown
> Moreover, if possible, will such Exceptions thrown on a SOAP::LiteYes. Since SOAP Faults are part of the spec, most clients allow you
> server-side be possible to be caught by non-SOAP::Lite clients?
to trap or detect a Fault in some way. PHP5, for example, throws an
exception if a function call results in a SOAP Fault, but each client
lib and/or language may deal with it differently.
Jay A. Kreibich | CommTech, Emrg Net Tech Svcs
jak@... | Campus IT & Edu Svcs
<http://www.uiuc.edu/~jak> | University of Illinois at U/C