I am not certain what you mean by "fault and exception handling".  You
say you are writing a service.  The service does not need to have
anything specific to SOAP.  You can handle exceptions the way you always
would, both catching exceptions you don't want propagating to the client
and throwing exceptions.  The Apache SOAP code will ultimately return a
SOAP fault to the client when your service throws an exception.  If you
want your faults to contain some specific information, you can write a
custom fault handler.  See
http://xml.apache.org/soap/docs/guide/errors.html.

The "standard" client code is something like this code from the
addressbook sample:

    // Invoke the call.
    Response resp;

    try
    {
      resp = call.invoke(url, "");
    }
    catch (SOAPException e)
    {
      System.err.println("Caught SOAPException (" +
                         e.getFaultCode() + "): " +
                         e.getMessage());
      return;
    }

    // Check the response.
    if (!resp.generatedFault())
    {
      Parameter ret = resp.getReturnValue();
      Object value = ret.getValue();

      System.out.println(value != null ? "\n" + value : "I don't
know.");
    }
    else
    {
      Fault fault = resp.getFault();

      System.err.println("Generated fault: " + fault);
    }

Scott Nichol

----- Original Message -----
From: "Ann-Cathrin Dykström" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 08, 2002 7:57 AM
Subject: Fault and exception handling


> Hi,
>
> I'm looking for examples of how fault and exception handling is done??
> I'm writing a SOAP web service in Java.
>
> /Annci
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to