org.apache.axis2
Class AxisFault

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by java.rmi.RemoteException
                  extended by org.apache.axis2.AxisFault
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ClusteringFault, DataRetrievalException, DeploymentException, MexException, PhaseException

public class AxisFault
extends java.rmi.RemoteException

An exception which maps cleanly to a SOAP fault. This is a base class for exceptions which are mapped to faults.

See Also:
SOAP1.2 specification, SOAP1.1 Faults

SOAP faults contain

  1. A fault string
  2. A fault code
  3. A fault actor
  4. Fault details; an xml tree of fault specific elements

As SOAP1.2 faults are a superset of SOAP1.1 faults, this type holds soap1.2 fault information. When a SOAP1.1 fault is created, spurious information can be discarded. Mapping

                                                             SOAP1.2              SOAP1.1
                                                             node                 faultactor
                                                             reason(0).text       faultstring
                                                             faultcode.value      faultcode
                                                             faultcode.subcode    (discarded)
                                                             detail               detail
                                                             role                 (discarded)
                                                             
, Serialized Form

Constructor Summary
  AxisFault(QName faultCode, java.util.List faultSubCodes, java.lang.String faultReason, java.lang.Throwable cause)
          Constructor
  AxisFault(QName faultCode, java.lang.String faultReason, java.lang.String faultNode, java.lang.String faultRole, org.apache.axiom.om.OMElement faultDetail)
          Constructor
  AxisFault(QName faultCode, java.lang.String faultReason, java.lang.Throwable cause)
          Constructor
  AxisFault(org.apache.axiom.soap.SOAPFault fault)
           
  AxisFault(org.apache.axiom.soap.SOAPFaultCode soapFaultCode, org.apache.axiom.soap.SOAPFaultReason soapFaultReason, org.apache.axiom.soap.SOAPFaultNode soapFaultNode, org.apache.axiom.soap.SOAPFaultRole soapFaultRole, org.apache.axiom.soap.SOAPFaultDetail soapFaultDetail)
          This is just a convenience method for the user.
  AxisFault(org.apache.axiom.soap.SOAPFault fault, MessageContext faultCtx)
           
  AxisFault(java.lang.String message)
          Constructor.
  AxisFault(java.lang.String message, MessageContext faultMessageContext)
          Create an AxisFault by providing a textual message and a MessageContext that contains the actual fault representation.
  AxisFault(java.lang.String message, MessageContext faultMessageContext, java.lang.Throwable cause)
           
  AxisFault(java.lang.String messageText, QName faultCode)
          Constructor
  AxisFault(java.lang.String messageText, QName faultCode, java.lang.Throwable cause)
           
  AxisFault(java.lang.String messageText, java.lang.String faultCode)
          Constructor.
  AxisFault(java.lang.String messageText, java.lang.String faultCode, java.lang.Throwable cause)
           
  AxisFault(java.lang.String message, java.lang.Throwable cause)
          Constructor
protected AxisFault(java.lang.Throwable cause)
          Construct a fault from a Throwable.
 
Method Summary
 void addHeader(org.apache.axiom.soap.SOAPHeaderBlock header)
          Add a header to the list of fault headers
 void addReason(java.lang.String text)
          Add a reason for the fault in the empty "" language
 void addReason(java.lang.String text, java.lang.String language)
          Add a reason for the fault
 org.apache.axiom.om.OMElement getDetail()
          Get the current fault detail
 java.lang.String getFaultAction()
           
 QName getFaultCode()
           
 org.apache.axiom.soap.SOAPFaultCode getFaultCodeElement()
           
 org.apache.axiom.soap.SOAPFaultDetail getFaultDetailElement()
           
 MessageContext getFaultMessageContext()
          Returns the MessageContext representation of the fault if the fault was created by providing that.
 java.lang.String getFaultNode()
           
 org.apache.axiom.soap.SOAPFaultNode getFaultNodeElement()
           
 org.apache.axiom.soap.SOAPFaultReason getFaultReasonElement()
           
 java.lang.String getFaultRole()
           
 org.apache.axiom.soap.SOAPFaultRole getFaultRoleElement()
           
 java.util.List getFaultSubCodes()
           
 int getFaultType()
           
 java.lang.String getMessage()
          Returns the detail message, including the message from the cause, if any, of this exception.
 java.lang.String getNodeURI()
          Get the faulting node uri.
 java.lang.String getReason()
          Returns the first fault reason, if available.
 java.util.ListIterator headerIterator()
          Iterate over all of the headers
 java.util.List headers()
          Get at the headers.
static AxisFault makeFault(java.lang.Throwable e)
          Make an AxisFault based on a passed Exception.
 void setDetail(org.apache.axiom.om.OMElement detail)
          Set the entire detail element of the fault
 void setFaultAction(java.lang.String faultAction)
          Set the (OPTIONAL) action value for the fault message
 void setFaultCode(QName soapFaultCode)
           
 void setFaultCode(java.lang.String soapFaultCode)
           
 void setFaultSubCodes(java.util.List faultSubCodes)
           
 void setFaultType(int faultType)
           
 void setNodeURI(java.lang.String nodeURI)
          Set the faulting node uri.
 
Methods inherited from class java.rmi.RemoteException
getCause
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, 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
 

Constructor Detail

AxisFault

public AxisFault(java.lang.String message)
Constructor.

Parameters:
message - the human-readable text describing the fault

AxisFault

public AxisFault(QName faultCode,
                 java.lang.String faultReason,
                 java.lang.Throwable cause)
Constructor

Parameters:
faultCode - - fault code of the message as a QName
faultReason - - the reason for the fault. The language will be defaulted to 'en'
cause - embedded fault which caused this one

AxisFault

public AxisFault(QName faultCode,
                 java.util.List faultSubCodes,
                 java.lang.String faultReason,
                 java.lang.Throwable cause)
Constructor

Parameters:
faultCode - - fault code of the message as a QName
faultSubCodes - - list sub fault codes as a list if QNames
faultReason - - the reason for the fault. The language will be defaulted to 'en'
cause - embedded fault which caused this one

AxisFault

public AxisFault(QName faultCode,
                 java.lang.String faultReason,
                 java.lang.String faultNode,
                 java.lang.String faultRole,
                 org.apache.axiom.om.OMElement faultDetail)
Constructor

Parameters:
faultCode - a QName for the fault code
faultReason - the reason for the fault. The language will be defaulted to 'en'
faultNode - a URL identifying the SOAP node generating this fault, or null
faultRole - a URL identifying the SOAP role active when generating this fault, or null
faultDetail - arbitrary XML containing application-specific fault data

AxisFault

public AxisFault(org.apache.axiom.soap.SOAPFaultCode soapFaultCode,
                 org.apache.axiom.soap.SOAPFaultReason soapFaultReason,
                 org.apache.axiom.soap.SOAPFaultNode soapFaultNode,
                 org.apache.axiom.soap.SOAPFaultRole soapFaultRole,
                 org.apache.axiom.soap.SOAPFaultDetail soapFaultDetail)
This is just a convenience method for the user. If you set these, do not use other methods in this class to get and set things. Any of the parameters can be null

Parameters:
soapFaultCode - the fault code
soapFaultReason - the fault reason
soapFaultNode - the SOAPFaultNode representing the source node for this fault
soapFaultRole - the SOAPFaultRole representing the source role for this fault
soapFaultDetail - the SOAPFaultDetail containing any application-specific info

AxisFault

public AxisFault(org.apache.axiom.soap.SOAPFault fault)

AxisFault

public AxisFault(org.apache.axiom.soap.SOAPFault fault,
                 MessageContext faultCtx)

AxisFault

protected AxisFault(java.lang.Throwable cause)
Construct a fault from a Throwable. This is a protected constructor - in general to make an AxisFault from an Exception, you should be calling AxisFault.makeFault(e), which prevents AxisFaults within AxisFaults.

Parameters:
cause - the Throwable that caused the problem

AxisFault

public AxisFault(java.lang.String messageText,
                 java.lang.String faultCode)
Constructor.

Parameters:
messageText - - this will appear as the Text in the Reason information item of SOAP Fault
faultCode - - this will appear as the Value in the Code information item of SOAP Fault

AxisFault

public AxisFault(java.lang.String messageText,
                 QName faultCode)
Constructor

Parameters:
messageText - this will appear as the Text in the Reason information item of SOAP Fault
faultCode - this will appear as the Value in the Code information item of SOAP Fault

AxisFault

public AxisFault(java.lang.String message,
                 java.lang.Throwable cause)
Constructor

Parameters:
message - this will appear as the Text in the Reason information item of SOAP Fault
cause - the embedded Throwable that caused this fault

AxisFault

public AxisFault(java.lang.String messageText,
                 QName faultCode,
                 java.lang.Throwable cause)
Parameters:
messageText - - this will appear as the Text in the Reason information item of SOAP Fault
faultCode - - this will appear as the Value in the Code information item of SOAP Fault
cause - - this will appear under the Detail information item of SOAP Fault

AxisFault

public AxisFault(java.lang.String message,
                 MessageContext faultMessageContext,
                 java.lang.Throwable cause)
Parameters:
message -
faultMessageContext -
cause -

AxisFault

public AxisFault(java.lang.String messageText,
                 java.lang.String faultCode,
                 java.lang.Throwable cause)
Parameters:
messageText - - this will appear as the Text in the Reason information item of SOAP Fault
faultCode - - this will appear as the Value in the Code information item of SOAP Fault
cause - - this will appear under the Detail information item of SOAP Fault

AxisFault

public AxisFault(java.lang.String message,
                 MessageContext faultMessageContext)
Create an AxisFault by providing a textual message and a MessageContext that contains the actual fault representation.

Parameters:
message - A string that's really only useful for logging.
faultMessageContext - A MessageContext which must contain SOAP fault info
Method Detail

addHeader

public void addHeader(org.apache.axiom.soap.SOAPHeaderBlock header)
Add a header to the list of fault headers

Parameters:
header - to add.

addReason

public void addReason(java.lang.String text)
Add a reason for the fault in the empty "" language

Parameters:
text - text message

addReason

public void addReason(java.lang.String text,
                      java.lang.String language)
Add a reason for the fault

Parameters:
text - text message
language - language

getReason

public java.lang.String getReason()
Returns the first fault reason, if available. If not found, returns null.

Returns:
faultReason

headerIterator

public java.util.ListIterator headerIterator()
Iterate over all of the headers

Returns:
iterator

headers

public java.util.List headers()
Get at the headers. Useful for java1.5 iteration.

Returns:
the headers for this fault

makeFault

public static AxisFault makeFault(java.lang.Throwable e)
Make an AxisFault based on a passed Exception. If the Exception is already an AxisFault, simply use that. Otherwise, wrap it in an AxisFault. If the Exception is an InvocationTargetException (which already wraps another Exception), get the wrapped Exception out from there and use that instead of the passed one.

Parameters:
e - the Exception to build a fault for
Returns:
an AxisFault representing e

getDetail

public org.apache.axiom.om.OMElement getDetail()
Get the current fault detail

Returns:
om element

getFaultCode

public QName getFaultCode()

getFaultSubCodes

public java.util.List getFaultSubCodes()

getFaultCodeElement

public org.apache.axiom.soap.SOAPFaultCode getFaultCodeElement()
Returns:
SOAPFaultCode if, user has set a SOAPFaultCode element when constructing the AxisFault

getFaultReasonElement

public org.apache.axiom.soap.SOAPFaultReason getFaultReasonElement()
Returns:
SOAPFaultCode if, user has set a SOAPFaultReason element when constructing the AxisFault

getFaultNodeElement

public org.apache.axiom.soap.SOAPFaultNode getFaultNodeElement()
Returns:
SOAPFaultCode if, user has set a SOAPFaultNode element when constructing the AxisFault

getFaultRoleElement

public org.apache.axiom.soap.SOAPFaultRole getFaultRoleElement()
Returns:
SOAPFaultCode if, user has set a SOAPFaultRole element when constructing the AxisFault

getFaultDetailElement

public org.apache.axiom.soap.SOAPFaultDetail getFaultDetailElement()
Returns:
SOAPFaultCode if, user has set a SOAPFaultDetail element when constructing the AxisFault

getNodeURI

public java.lang.String getNodeURI()
Get the faulting node uri. SOAP1.2

Returns:
URI as a string or null

setDetail

public void setDetail(org.apache.axiom.om.OMElement detail)
Set the entire detail element of the fault

Parameters:
detail - an OMElement which MUST be

setFaultCode

public void setFaultCode(QName soapFaultCode)

setFaultSubCodes

public void setFaultSubCodes(java.util.List faultSubCodes)

setFaultCode

public void setFaultCode(java.lang.String soapFaultCode)

setNodeURI

public void setNodeURI(java.lang.String nodeURI)
Set the faulting node uri. (SOAP1.2)

Parameters:
nodeURI - a String containing a URI indicating which SOAP Node faulted

getFaultNode

public java.lang.String getFaultNode()

getFaultRole

public java.lang.String getFaultRole()

getFaultMessageContext

public MessageContext getFaultMessageContext()
Returns the MessageContext representation of the fault if the fault was created by providing that.

Returns:
The MessageContext representing the fault message or null if the fault was not created with MessageContext representation.

getFaultAction

public java.lang.String getFaultAction()
Returns:
the action value set for the fault message

setFaultAction

public void setFaultAction(java.lang.String faultAction)
Set the (OPTIONAL) action value for the fault message

Parameters:
faultAction - a String containing an action URI for the fault

getMessage

public java.lang.String getMessage()
Returns the detail message, including the message from the cause, if any, of this exception.

Overrides:
getMessage in class java.rmi.RemoteException
Returns:
the detail message

getFaultType

public int getFaultType()

setFaultType

public void setFaultType(int faultType)


Copyright © 2007 Apache Web Services Project. All Rights Reserved.