Release 10.1A: OpenEdge Development:
Web Services

> ## Handling errors on the client

> To understand how to handle SOAP fault messages returned by the WSA, first note that the `<FaultDetail>` element is described in the interface Java class, `servicehost/FaultDetail.java`. For examples:

>     public class FaultDetail {
>        java.lang.String errorMessage;
>        java.lang.String requestID;
>        ...
>     }

> Place a `try...catch` block around any code that accesses the Web server and catch the `AxisFault` exception.

> This is an example of Axis client code to catch a SOAP fault (an `AxisFault` exception):

>     try
>     {
>         // code to Access the Web Service
>     }
>     catch (AxisFault e)
>     {
>         // Get the (single) child element of the SOAP Fault <detail> element,
>         // the <FaultDetail> element.
>         Element[] faultDetails = e.getFaultDetails( );
>         if (faultDetails.length > 0)
>         {
>             // Now get the contents of the <FaultDetail> element,
>             //    <errorMessage> and <requestID>.
>             Node     faultDetailElem = faultDetails[0].getFirstChild( );
>             String   detailErrorMsg =
>                faultDetailElem.getFirstChild( ).getNodeValue( );
>             System.err.println("Exception errorMessage: " + detailErrorMsg);
>             Node     requestIDElem = faultDetailElem.getNextSibling( );
>             String   requestID = requestIDElem.getFirstChild( ).getNodeValue( );
>             System.err.println("Exception requestID   : " + requestID);
>         }
>     }

> Caution: In any `catch` block where you exit the program, you must release all Web service objects you created in the program.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095