Listing 3. This stubs-based Web service client handles the SOAPFaultException.

import javax.xml.rpc.soap.SOAPFaultException;
import java.rmi.RemoteException;

public final class Client {

   public Client() {}

   public static void main(String[] argv) 
      throws Exception
      {
      // Setup the global JAXM message factory
      System.setProperty(
         "javax.xml.soap.MessageFactory",
         "weblogic.webservice.core.soap.
         MessageFactoryImpl");
      // Setup the global JAX-RPC service factory
      System.setProperty(
         "javax.xml.rpc.ServiceFactory",
         "weblogic.webservice.core.rpc.
         ServiceFactoryImpl");

      HelloWorld_Impl ws = 
         new HelloWorld_Impl(argv[0]);
      HelloWorldPort port  = ws.getHelloWorldPort();

      try {
      port.sendSOAPFault();
      } // try
      catch(SOAPFaultException ex) {
         System.out.println(ex.toString());
         ex.printStackTrace();
      }
      catch(RemoteException ex) {
         if (ex.getCause() instanceof 
         SOAPFaultException) {
      SOAPFaultException fault = 
         (SOAPFaultException)ex.getCause();
      System.out.println("[Client] Fault Detail : " + 
         fault.getDetail().toString());
      System.out.println("[Client] Fault Actor : " + 
         fault.getFaultActor());
      System.out.println("[Client] Fault String : " + 
         fault.getFaultString());
      }
      System.out.println("[Client] 
         Exception stack trace :");
         ex.printStackTrace();
      }

   }
}