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 .NET 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
Product edition availability:
  • WebORB Standard Edition (localhost clients only)
  • WebORB Professional Edition
  • WebORB Enterprise Edition
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:
     

    using System;
    using
    System.Collections;
    using
    System.Text;

    namespace
    Weborb.Examples
    {
        public class ExceptionsTest
        {
            public void divByZero()
            {
                int zero = 0;
                int five = 5;
                int result = five / zero;
            }

            public void NPE()
            {
                Hashtable hash = new Hashtable();
                hash.Add( null, null );
            }

            public void throwException()
            {
                throw new MyException( "this is a custom application exception" );
            }
        }

        public class MyException : Exception
        {
            public MyException( String message )
                : base( message )
            {
            }
        }
    }


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