org.codehaus.xfire.fault
Class XFireFault

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.codehaus.xfire.XFireException
              extended by org.codehaus.xfire.fault.XFireFault
All Implemented Interfaces:
Serializable

public class XFireFault
extends XFireException

In XFire, applications throw their own declared exceptions which are then turned into faults. The XFireFault class wraps these exceptions extracting out the details for the fault message.

If the developer wishes to generate their own custom fault messages, they can either override XFireFault to provide the FaultHandlers with the necessary information or write a new FaultHandler.

TODO Add i18n support

Since:
Feb 14, 2004
Author:
Dan Diephouse
See Also:
Serialized Form

Field Summary
static QName DATA_ENCODING_UNKNOWN
           
static QName MUST_UNDERSTAND
           
static QName RECEIVER
          A SOAP 1.2 only fault code.
static QName SENDER
          "The message was incorrectly formed or did not contain the appropriate information in order to succeed." -- SOAP 1.2 Spec
static QName SOAP11_CLIENT
           
static QName SOAP11_MUST_UNDERSTAND
           
static QName SOAP11_SERVER
           
static QName SOAP11_VERSION_MISMATCH
           
static QName VERSION_MISMATCH
           
 
Constructor Summary
protected XFireFault()
           
  XFireFault(String message, QName code)
          Create an exception wih the specified fault message and faultCode.
  XFireFault(String message, Throwable cause, QName code)
          Create a fault.
  XFireFault(Throwable throwable)
          Create a fault for the specified exception.
  XFireFault(Throwable throwable, QName code)
          Create a fault with the specified faultCode.
 
Method Summary
 void addNamespace(String prefix, String ns)
          Adds a namespace with prefix to this fault.
static XFireFault createFault(Throwable throwable)
          Creates a XFireFault from the given throwable.
 org.jdom.Element getDetail()
          Returns the detail node.
 QName getFaultCode()
          Returns the fault code of this fault.
 String getMessage()
          Returns the detail message string of this fault.
 Map getNamespaces()
          User defined namespaces which will be written out on the resultant SOAP Fault (for use easy with SubCodes and Detail) elements.
 String getReason()
           
 String getRole()
          Returns the fault actor.
 QName getSubCode()
          Returns the SubCode for the Fault Code.
 boolean hasDetails()
          Indicates whether this fault has a detail message.
 void setDetail(org.jdom.Element details)
          Sets a details Node on this fault.
 void setFaultCode(QName faultCode)
          Sets the fault code of this fault.
 void setMessage(String message)
           
 void setRole(String actor)
          Sets the fault actor.
 void setSubCode(QName subCode)
          Sets the SubCode for the Fault Code.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_MISMATCH

public static final QName VERSION_MISMATCH

MUST_UNDERSTAND

public static final QName MUST_UNDERSTAND

DATA_ENCODING_UNKNOWN

public static final QName DATA_ENCODING_UNKNOWN

SENDER

public static final QName SENDER
"The message was incorrectly formed or did not contain the appropriate information in order to succeed." -- SOAP 1.2 Spec


RECEIVER

public static final QName RECEIVER
A SOAP 1.2 only fault code.

"The message could not be processed for reasons attributable to the processing of the message rather than to the contents of the message itself." -- SOAP 1.2 Spec

If this message is used in a SOAP 1.1 Fault it will most likely (depending on the FaultHandler) be mapped to "Sender" instead.


SOAP11_SERVER

public static final QName SOAP11_SERVER

SOAP11_CLIENT

public static final QName SOAP11_CLIENT

SOAP11_MUST_UNDERSTAND

public static final QName SOAP11_MUST_UNDERSTAND

SOAP11_VERSION_MISMATCH

public static final QName SOAP11_VERSION_MISMATCH
Constructor Detail

XFireFault

protected XFireFault()

XFireFault

public XFireFault(Throwable throwable)
Create a fault for the specified exception. The faultCode is set to RECEIVER.

Parameters:
throwable -

XFireFault

public XFireFault(Throwable throwable,
                  QName code)
Create a fault with the specified faultCode. The exception message is used for the fault message.

Parameters:
throwable - The exception that caused this fault.
code - The fault code. See XFireFault's static fields.

XFireFault

public XFireFault(String message,
                  QName code)
Create an exception wih the specified fault message and faultCode.

Parameters:
message - The fault message.
code - The fault code. See XFireFault's static fields.

XFireFault

public XFireFault(String message,
                  Throwable cause,
                  QName code)
Create a fault.

Parameters:
cause - The exception which caused this fault.
code - The fault code. See XFireFault's static fields.
Method Detail

createFault

public static XFireFault createFault(Throwable throwable)
Creates a XFireFault from the given throwable. If the throwable is a XFireFault, it is not wrapped.

Parameters:
throwable - the throwable
Returns:
the fault

addNamespace

public void addNamespace(String prefix,
                         String ns)
Adds a namespace with prefix to this fault.

Parameters:
prefix - the prefix
ns - the namespace.

getDetail

public org.jdom.Element getDetail()
Returns the detail node. If no detail node has been set, an empty <detail> is created.

Returns:
the detail node.

setDetail

public void setDetail(org.jdom.Element details)
Sets a details Node on this fault.

Parameters:
details - the detail node.

getFaultCode

public QName getFaultCode()
Returns the fault code of this fault.

Returns:
the fault code.

setFaultCode

public void setFaultCode(QName faultCode)
Sets the fault code of this fault.

Parameters:
faultCode - the fault code.

getMessage

public String getMessage()
Returns the detail message string of this fault.

Overrides:
getMessage in class Throwable
Returns:
the detail message string of this XfireFault (which may be null)

setMessage

public void setMessage(String message)
Parameters:
message - The message to set.

getNamespaces

public Map getNamespaces()
User defined namespaces which will be written out on the resultant SOAP Fault (for use easy with SubCodes and Detail) elements.

Returns:

getReason

public String getReason()

getRole

public String getRole()
Returns the fault actor.

Returns:
the fault actor.

setRole

public void setRole(String actor)
Sets the fault actor.

Parameters:
actor - the actor.

getSubCode

public QName getSubCode()
Returns the SubCode for the Fault Code.

Returns:
The SubCode element as detailed by the SOAP 1.2 spec.

setSubCode

public void setSubCode(QName subCode)
Sets the SubCode for the Fault Code.

Parameters:
subCode - The SubCode element as detailed by the SOAP 1.2 spec.

hasDetails

public boolean hasDetails()
Indicates whether this fault has a detail message.

Returns:
true if this fault has a detail message; false otherwise.


Copyright © 2004-2013. All Rights Reserved.