You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Shimmie <sh...@shimmie.com> on 2002/07/15 15:20:41 UTC

SOAP Exception vs. Fault

All the sample code I see checks for an exception and then check for a response fault. E.g.,
  try {
      resp = call.invoke(url, "");
  } catch (SOAPException e) {
      // handle exception
      return
  }

  if (!resp.generatedFault()) {
      Parameter ret = resp.getReturnValue();
      if (ret != null) result = ret.getValue();
  } else {
      Fault fault = resp.getFault();
      // handle the fault
  }
Is an exception thrown every time there is a fault? Is there a fault everytime there is an exception? Or if these are two very different beasts, is there any guilde lines as to when one is used or the other (or is it like returning int error codes vs. throwing exceptions)?

Thanks,

Simon.



Re: SOAP Exception vs. Fault

Posted by Praveen Peddi <pp...@contextmedia.com>.
Dan is absolutely right! Number 2 is definitely correct.

Server side cannot be caught by the client. The client should check if response.generateFault() is true and then get the information about the server side exception using the Fault object.

Simon could you send me the output of the exception you were talking about. You might have mistaken the soap exception with ur server side exception.

Praveen
  ----- Original Message ----- 
  From: Dan Allen 
  To: soap-user@xml.apache.org 
  Sent: Tuesday, July 16, 2002 9:31 AM
  Subject: RE: SOAP Exception vs. Fault



      Number 2 is not wrong. For a definitive answer, look at the source for RPCRouterServlet.java and MessageRouterServlet.java.
     The try/catch  blocks are designed to return a SOAPFault for all exceptions that are thrown during message processing.  However,
     any exception thrown while processing a thrown exception will be returned by the servlet container in whatever fashion it choses
     to handle servlet failures.  This will almost surely not be a SOAP message. If you attempt to construct a SOAP message from 
     such a response you will most likely generate a client side exception.

      The SOAPException caught in the sample client code below is a client side fault.  You can't catch a server side exception
      in the client.

      Dan
    -----Original Message-----
    From: Shimmie [mailto:shimmie@shimmie.com]
    Sent: Monday, July 15, 2002 4:39 PM
    To: soap-user@xml.apache.org
    Subject: Re: SOAP Exception vs. Fault


    I know at least (2) is wrong. My (valid) service threw an exception, and my client got a SOAPException.

    Can anyone point me to documentation about how this all works? The java doc doesn't make mention of it.

    Thanks,

    Simon.
      ----- Original Message ----- 
      From: Praveen Peddi 
      To: soap-user@xml.apache.org 
      Sent: Tuesday, July 16, 2002 12:46 AM
      Subject: Re: SOAP Exception vs. Fault


      I think this is how Apache SOAP API works.

      1) If the soap is installed properly on the server, but the client cannot find the requested service, it generates the fault.
      2) If the client finds the requested service, but the exception is thrown by the service, it generates a fault. In this case you do not catch the exception but you check this using response.generatedFault() method.
      3) If the soap is not installed properly, then it throws SOAPException.

      Correct me if I am wrong!!

      Praveen

        All the sample code I see checks for an exception and then check for a response fault. E.g.,
          try {
              resp = call.invoke(url, "");
          } catch (SOAPException e) {
              // handle exception
              return
          }

          if (!resp.generatedFault()) {
              Parameter ret = resp.getReturnValue();
              if (ret != null) result = ret.getValue();
          } else {
              Fault fault = resp.getFault();
              // handle the fault
          }
        Is an exception thrown every time there is a fault? Is there a fault everytime there is an exception? Or if these are two very different beasts, is there any guilde lines as to when one is used or the other (or is it like returning int error codes vs. throwing exceptions)?

        Thanks,

        Simon.


Re: SOAP Exception vs. Fault

Posted by Praveen Peddi <pp...@contextmedia.com>.
Dan is absolutely right! Number 2 is definitely correct.

Server side cannot be caught by the client. The client should check if response.generateFault() is true and then get the information about the server side exception using the Fault object.

Simon could you send me the output of the exception you were talking about. You might have mistaken the soap exception with ur server side exception.

Praveen
  ----- Original Message ----- 
  From: Dan Allen 
  To: soap-user@xml.apache.org 
  Sent: Tuesday, July 16, 2002 9:31 AM
  Subject: RE: SOAP Exception vs. Fault



      Number 2 is not wrong. For a definitive answer, look at the source for RPCRouterServlet.java and MessageRouterServlet.java.
     The try/catch  blocks are designed to return a SOAPFault for all exceptions that are thrown during message processing.  However,
     any exception thrown while processing a thrown exception will be returned by the servlet container in whatever fashion it choses
     to handle servlet failures.  This will almost surely not be a SOAP message. If you attempt to construct a SOAP message from 
     such a response you will most likely generate a client side exception.

      The SOAPException caught in the sample client code below is a client side fault.  You can't catch a server side exception
      in the client.

      Dan
    -----Original Message-----
    From: Shimmie [mailto:shimmie@shimmie.com]
    Sent: Monday, July 15, 2002 4:39 PM
    To: soap-user@xml.apache.org
    Subject: Re: SOAP Exception vs. Fault


    I know at least (2) is wrong. My (valid) service threw an exception, and my client got a SOAPException.

    Can anyone point me to documentation about how this all works? The java doc doesn't make mention of it.

    Thanks,

    Simon.
      ----- Original Message ----- 
      From: Praveen Peddi 
      To: soap-user@xml.apache.org 
      Sent: Tuesday, July 16, 2002 12:46 AM
      Subject: Re: SOAP Exception vs. Fault


      I think this is how Apache SOAP API works.

      1) If the soap is installed properly on the server, but the client cannot find the requested service, it generates the fault.
      2) If the client finds the requested service, but the exception is thrown by the service, it generates a fault. In this case you do not catch the exception but you check this using response.generatedFault() method.
      3) If the soap is not installed properly, then it throws SOAPException.

      Correct me if I am wrong!!

      Praveen

        All the sample code I see checks for an exception and then check for a response fault. E.g.,
          try {
              resp = call.invoke(url, "");
          } catch (SOAPException e) {
              // handle exception
              return
          }

          if (!resp.generatedFault()) {
              Parameter ret = resp.getReturnValue();
              if (ret != null) result = ret.getValue();
          } else {
              Fault fault = resp.getFault();
              // handle the fault
          }
        Is an exception thrown every time there is a fault? Is there a fault everytime there is an exception? Or if these are two very different beasts, is there any guilde lines as to when one is used or the other (or is it like returning int error codes vs. throwing exceptions)?

        Thanks,

        Simon.


RE: SOAP Exception vs. Fault

Posted by Dan Allen <da...@nist.gov>.
    Number 2 is not wrong. For a definitive answer, look at the source for
RPCRouterServlet.java and MessageRouterServlet.java.
   The try/catch  blocks are designed to return a SOAPFault for all
exceptions that are thrown during message processing.  However,
   any exception thrown while processing a thrown exception will be returned
by the servlet container in whatever fashion it choses
   to handle servlet failures.  This will almost surely not be a SOAP
message. If you attempt to construct a SOAP message from
   such a response you will most likely generate a client side exception.

    The SOAPException caught in the sample client code below is a client
side fault.  You can't catch a server side exception
    in the client.

    Dan
  -----Original Message-----
  From: Shimmie [mailto:shimmie@shimmie.com]
  Sent: Monday, July 15, 2002 4:39 PM
  To: soap-user@xml.apache.org
  Subject: Re: SOAP Exception vs. Fault


  I know at least (2) is wrong. My (valid) service threw an exception, and
my client got a SOAPException.

  Can anyone point me to documentation about how this all works? The java
doc doesn't make mention of it.

  Thanks,

  Simon.
    ----- Original Message -----
    From: Praveen Peddi
    To: soap-user@xml.apache.org
    Sent: Tuesday, July 16, 2002 12:46 AM
    Subject: Re: SOAP Exception vs. Fault


    I think this is how Apache SOAP API works.

    1) If the soap is installed properly on the server, but the client
cannot find the requested service, it generates the fault.
    2) If the client finds the requested service, but the exception is
thrown by the service, it generates a fault. In this case you do not catch
the exception but you check this using response.generatedFault() method.
    3) If the soap is not installed properly, then it throws SOAPException.

    Correct me if I am wrong!!

    Praveen

      All the sample code I see checks for an exception and then check for a
response fault. E.g.,
        try {
            resp = call.invoke(url, "");
        } catch (SOAPException e) {
            // handle exception
            return
        }

        if (!resp.generatedFault()) {
            Parameter ret = resp.getReturnValue();
            if (ret != null) result = ret.getValue();
        } else {
            Fault fault = resp.getFault();
            // handle the fault
        }
      Is an exception thrown every time there is a fault? Is there a fault
everytime there is an exception? Or if these are two very different beasts,
is there any guilde lines as to when one is used or the other (or is it like
returning int error codes vs. throwing exceptions)?

      Thanks,

      Simon.



RE: SOAP Exception vs. Fault

Posted by Dan Allen <da...@nist.gov>.
    Number 2 is not wrong. For a definitive answer, look at the source for
RPCRouterServlet.java and MessageRouterServlet.java.
   The try/catch  blocks are designed to return a SOAPFault for all
exceptions that are thrown during message processing.  However,
   any exception thrown while processing a thrown exception will be returned
by the servlet container in whatever fashion it choses
   to handle servlet failures.  This will almost surely not be a SOAP
message. If you attempt to construct a SOAP message from
   such a response you will most likely generate a client side exception.

    The SOAPException caught in the sample client code below is a client
side fault.  You can't catch a server side exception
    in the client.

    Dan
  -----Original Message-----
  From: Shimmie [mailto:shimmie@shimmie.com]
  Sent: Monday, July 15, 2002 4:39 PM
  To: soap-user@xml.apache.org
  Subject: Re: SOAP Exception vs. Fault


  I know at least (2) is wrong. My (valid) service threw an exception, and
my client got a SOAPException.

  Can anyone point me to documentation about how this all works? The java
doc doesn't make mention of it.

  Thanks,

  Simon.
    ----- Original Message -----
    From: Praveen Peddi
    To: soap-user@xml.apache.org
    Sent: Tuesday, July 16, 2002 12:46 AM
    Subject: Re: SOAP Exception vs. Fault


    I think this is how Apache SOAP API works.

    1) If the soap is installed properly on the server, but the client
cannot find the requested service, it generates the fault.
    2) If the client finds the requested service, but the exception is
thrown by the service, it generates a fault. In this case you do not catch
the exception but you check this using response.generatedFault() method.
    3) If the soap is not installed properly, then it throws SOAPException.

    Correct me if I am wrong!!

    Praveen

      All the sample code I see checks for an exception and then check for a
response fault. E.g.,
        try {
            resp = call.invoke(url, "");
        } catch (SOAPException e) {
            // handle exception
            return
        }

        if (!resp.generatedFault()) {
            Parameter ret = resp.getReturnValue();
            if (ret != null) result = ret.getValue();
        } else {
            Fault fault = resp.getFault();
            // handle the fault
        }
      Is an exception thrown every time there is a fault? Is there a fault
everytime there is an exception? Or if these are two very different beasts,
is there any guilde lines as to when one is used or the other (or is it like
returning int error codes vs. throwing exceptions)?

      Thanks,

      Simon.



Re: SOAP Exception vs. Fault

Posted by Shimmie <sh...@shimmie.com>.
I know at least (2) is wrong. My (valid) service threw an exception, and my client got a SOAPException.

Can anyone point me to documentation about how this all works? The java doc doesn't make mention of it.

Thanks,

Simon.
  ----- Original Message ----- 
  From: Praveen Peddi 
  To: soap-user@xml.apache.org 
  Sent: Tuesday, July 16, 2002 12:46 AM
  Subject: Re: SOAP Exception vs. Fault


  I think this is how Apache SOAP API works.

  1) If the soap is installed properly on the server, but the client cannot find the requested service, it generates the fault.
  2) If the client finds the requested service, but the exception is thrown by the service, it generates a fault. In this case you do not catch the exception but you check this using response.generatedFault() method.
  3) If the soap is not installed properly, then it throws SOAPException.

  Correct me if I am wrong!!

  Praveen

    All the sample code I see checks for an exception and then check for a response fault. E.g.,
      try {
          resp = call.invoke(url, "");
      } catch (SOAPException e) {
          // handle exception
          return
      }

      if (!resp.generatedFault()) {
          Parameter ret = resp.getReturnValue();
          if (ret != null) result = ret.getValue();
      } else {
          Fault fault = resp.getFault();
          // handle the fault
      }
    Is an exception thrown every time there is a fault? Is there a fault everytime there is an exception? Or if these are two very different beasts, is there any guilde lines as to when one is used or the other (or is it like returning int error codes vs. throwing exceptions)?

    Thanks,

    Simon.



Re: SOAP Exception vs. Fault

Posted by Shimmie <sh...@shimmie.com>.
I know at least (2) is wrong. My (valid) service threw an exception, and my client got a SOAPException.

Can anyone point me to documentation about how this all works? The java doc doesn't make mention of it.

Thanks,

Simon.
  ----- Original Message ----- 
  From: Praveen Peddi 
  To: soap-user@xml.apache.org 
  Sent: Tuesday, July 16, 2002 12:46 AM
  Subject: Re: SOAP Exception vs. Fault


  I think this is how Apache SOAP API works.

  1) If the soap is installed properly on the server, but the client cannot find the requested service, it generates the fault.
  2) If the client finds the requested service, but the exception is thrown by the service, it generates a fault. In this case you do not catch the exception but you check this using response.generatedFault() method.
  3) If the soap is not installed properly, then it throws SOAPException.

  Correct me if I am wrong!!

  Praveen

    All the sample code I see checks for an exception and then check for a response fault. E.g.,
      try {
          resp = call.invoke(url, "");
      } catch (SOAPException e) {
          // handle exception
          return
      }

      if (!resp.generatedFault()) {
          Parameter ret = resp.getReturnValue();
          if (ret != null) result = ret.getValue();
      } else {
          Fault fault = resp.getFault();
          // handle the fault
      }
    Is an exception thrown every time there is a fault? Is there a fault everytime there is an exception? Or if these are two very different beasts, is there any guilde lines as to when one is used or the other (or is it like returning int error codes vs. throwing exceptions)?

    Thanks,

    Simon.



Re: SOAP Exception vs. Fault

Posted by Praveen Peddi <pp...@contextmedia.com>.
I think this is how Apache SOAP API works.

1) If the soap is installed properly on the server, but the client cannot find the requested service, it generates the fault.
2) If the client finds the requested service, but the exception is thrown by the service, it generates a fault. In this case you do not catch the exception but you check this using response.generatedFault() method.
3) If the soap is not installed properly, then it throws SOAPException.

Correct me if I am wrong!!

Praveen

  All the sample code I see checks for an exception and then check for a response fault. E.g.,
    try {
        resp = call.invoke(url, "");
    } catch (SOAPException e) {
        // handle exception
        return
    }

    if (!resp.generatedFault()) {
        Parameter ret = resp.getReturnValue();
        if (ret != null) result = ret.getValue();
    } else {
        Fault fault = resp.getFault();
        // handle the fault
    }
  Is an exception thrown every time there is a fault? Is there a fault everytime there is an exception? Or if these are two very different beasts, is there any guilde lines as to when one is used or the other (or is it like returning int error codes vs. throwing exceptions)?

  Thanks,

  Simon.


Re: SOAP Exception vs. Fault

Posted by Praveen Peddi <pp...@contextmedia.com>.
I think this is how Apache SOAP API works.

1) If the soap is installed properly on the server, but the client cannot find the requested service, it generates the fault.
2) If the client finds the requested service, but the exception is thrown by the service, it generates a fault. In this case you do not catch the exception but you check this using response.generatedFault() method.
3) If the soap is not installed properly, then it throws SOAPException.

Correct me if I am wrong!!

Praveen

  All the sample code I see checks for an exception and then check for a response fault. E.g.,
    try {
        resp = call.invoke(url, "");
    } catch (SOAPException e) {
        // handle exception
        return
    }

    if (!resp.generatedFault()) {
        Parameter ret = resp.getReturnValue();
        if (ret != null) result = ret.getValue();
    } else {
        Fault fault = resp.getFault();
        // handle the fault
    }
  Is an exception thrown every time there is a fault? Is there a fault everytime there is an exception? Or if these are two very different beasts, is there any guilde lines as to when one is used or the other (or is it like returning int error codes vs. throwing exceptions)?

  Thanks,

  Simon.