Loading ...
Sorry, an error occurred while loading the content.

Throwing Exceptions from Server to Client

Expand Messages
  • Sebastien Boving & Nicole Kersting
    Hi, 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
    Message 1 of 2 , Mar 24, 2005
    • 0 Attachment
      Hi,

      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?

      thank you,
      -seb.
    • Jay A. Kreibich
      ... Sort of. SOAP has the concept of a Fault that indicates a operational error. Actually, you can use them for anything, but they re usually used to
      Message 2 of 2 , Mar 24, 2005
      • 0 Attachment
        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 the
        > server-side, and catch these on the client-side? And how ;)?

        Sort of. SOAP has the concept of a "Fault" that indicates a
        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 )
        {
        die SOAP::Fault
        -> 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
        exception.

        > Moreover, if possible, will such Exceptions thrown on a SOAP::Lite
        > server-side be possible to be caught by non-SOAP::Lite clients?

        Yes. Since SOAP Faults are part of the spec, most clients allow you
        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.

        -j

        --
        Jay A. Kreibich | CommTech, Emrg Net Tech Svcs
        jak@... | Campus IT & Edu Svcs
        <http://www.uiuc.edu/~jak> | University of Illinois at U/C
      Your message has been successfully submitted and would be delivered to recipients shortly.