Example name: Remote Invocation Exception Handling
Description: The example demonstrates the following:
  • Handling of exceptions thrown from remote method invocations
  • Demonstration of the exception object field values delivered to the client

The client application invokes methods in a PHP object causing exceptions. WebORB intercepts the exceptions and delivers them as errors to the client.

Client-side code: Browse  Download
Server-side code: Browse  Download
Run example:
Key points:
  • Any exception generated by the server-code is delivered to the client with the same error message. Consider the server-side code behind this example:
     
    require_once ("MyException.php");
    class ExceptionsTest
    {
       public function divByZero()
       {
         return 5 / 0;
       }

      public function NPE()
       {
          $o = null;
          $o->test();
       }

      public function throwException()
       {
         throw new MyException( "this is a custom application exception" );
       }
    }
    class MyException extends Exception
    {
       public $message;

       function __construct($message)
       {
          $this->message = $message;
       }
    }

  • The best way to get the message of the remote exception is by using the "faultString" property of the fault object.