org.apache.axis
Class AxisFault

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--java.io.IOException
                    |
                    +--java.rmi.RemoteException
                          |
                          +--org.apache.axis.AxisFault
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NoEndPointException

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. SOAP faults contain

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

Author:
Doug Davis (dug@us.ibm.com), James Snell (jasnell@us.ibm.com)
See Also:
Serialized Form

Field Summary
protected  java.lang.String faultActor
           
protected  QName faultCode
           
protected  java.util.Vector faultDetails
           
protected  java.util.ArrayList faultHeaders
          SOAP headers which should be serialized with the Fault
protected  java.lang.String faultNode
           
protected  java.lang.String faultString
           
protected  java.util.Vector faultSubCode
           
protected static org.apache.commons.logging.Log log
           
 
Fields inherited from class java.rmi.RemoteException
detail
 
Constructor Summary
  AxisFault()
          No-arg constructor for building one from an XML stream.
protected AxisFault(java.lang.Exception target)
          Wrap an AxisFault around an existing Exception - this is private to force everyone to use makeFault() above, which sanity-checks us.
  AxisFault(QName code, QName[] subcodes, java.lang.String faultString, java.lang.String actor, java.lang.String node, org.w3c.dom.Element[] details)
          make a fault in any namespace
  AxisFault(QName code, java.lang.String faultString, java.lang.String actor, org.w3c.dom.Element[] details)
          make a fault in any namespace
  AxisFault(java.lang.String message)
          create a simple axis fault from the message.
  AxisFault(java.lang.String code, java.lang.String faultString, java.lang.String actor, org.w3c.dom.Element[] details)
          make a fault
  AxisFault(java.lang.String message, java.lang.Throwable t)
          create a fault from any throwable; When faulting a throwable (as opposed to an exception), stack trace information does not go into the fault.
 
Method Summary
 void addFaultDetailString(java.lang.String detail)
          parse an XML fragment and add it as a single element in the fault detail xml
 void addFaultSubCode(QName code)
          This is new in SOAP 1.2, ignored in SOAP 1.1
 void addFaultSubCodeAsString(java.lang.String code)
          This is new in SOAP 1.2, ignored in SOAP 1.1
 void addHeader(SOAPHeaderElement header)
          Add a SOAP header which should be serialized along with the fault.
 void clearFaultSubCodes()
          This is new in SOAP 1.2, ignored in SOAP 1.1
 void clearHeaders()
          clear all fault headers
 void dump()
          dump the fault info to the log at debug level
 java.lang.String dumpToString()
          turn the fault and details into a string
 java.lang.String getFaultActor()
          get the fault actor
 QName getFaultCode()
          get the fault code
 org.w3c.dom.Element[] getFaultDetails()
          get all the fault details
 java.lang.String getFaultNode()
          This is new in SOAP 1.2
 java.lang.String getFaultReason()
          This is SOAP 1.2 equivalent of getFaultString()
 java.lang.String getFaultRole()
          This is SOAP 1.2 equivalent of getFaultActor()
 java.lang.String getFaultString()
          get the fault string; this will never be null but may be the empty string
 QName[] getFaultSubCodes()
           
static AxisFault makeFault(java.lang.Exception e)
          Make an AxisFault based on a passed Exception.
 void output(SerializationContext context)
          add this fault and any needed headers to the output context
 void printStackTrace(java.io.PrintStream ps)
          The override of the base class method prints out the fault info before the stack trace
 void printStackTrace(java.io.PrintWriter pw)
          The override of the base class method prints out the fault info before the stack trace
 void setFaultActor(java.lang.String actor)
          set the fault actor
 void setFaultCode(QName code)
          set the fault code
 void setFaultCodeAsString(java.lang.String code)
          set a fault code string that is turned into a qname in the axis namespace
 void setFaultDetail(org.w3c.dom.Element[] details)
          the fault detail element to the arrary of details
 void setFaultDetailString(java.lang.String details)
          turn a string containing an xml fragment into the fault details
 void setFaultNode(java.lang.String node)
          This is new in SOAP 1.2
 void setFaultReason(java.lang.String str)
          This is SOAP 1.2 equivalent of setFaultString(java.lang.String)
 void setFaultRole(java.lang.String role)
          This is SOAP 1.2 equivalent of setFaultActor(java.lang.String)
 void setFaultString(java.lang.String str)
          set a fault string;
 java.lang.String toString()
          string operator
 void writeDetails(QName qname, SerializationContext context)
          Writes any exception data to the faultDetails This is for overriding; it is empty in the base AxisFault
 
Methods inherited from class java.rmi.RemoteException
getMessage, printStackTrace
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

faultCode

protected QName faultCode

faultSubCode

protected java.util.Vector faultSubCode

faultString

protected java.lang.String faultString

faultActor

protected java.lang.String faultActor

faultDetails

protected java.util.Vector faultDetails

faultNode

protected java.lang.String faultNode

faultHeaders

protected java.util.ArrayList faultHeaders
SOAP headers which should be serialized with the Fault
Constructor Detail

AxisFault

public AxisFault(java.lang.String code,
                 java.lang.String faultString,
                 java.lang.String actor,
                 org.w3c.dom.Element[] details)
make a fault
Parameters:
code - fault code which will be passed into the Axis namespace
faultString - fault string
actor - fault actor
details - details; if null the current stack trace and classname is inserted into the details.

AxisFault

public AxisFault(QName code,
                 java.lang.String faultString,
                 java.lang.String actor,
                 org.w3c.dom.Element[] details)
make a fault in any namespace
Parameters:
code - fault code which will be passed into the Axis namespace
faultString - fault string
actor - fault actor
details - details; if null the current stack trace and classname is inserted into the details.

AxisFault

public AxisFault(QName code,
                 QName[] subcodes,
                 java.lang.String faultString,
                 java.lang.String actor,
                 java.lang.String node,
                 org.w3c.dom.Element[] details)
make a fault in any namespace
Parameters:
code - fault code which will be passed into the Axis namespace
subcodes - fault subcodes which will be pased into the Axis namespace
faultString - fault string
actor - fault actor, same as fault role in SOAP 1.2
node - which node caused the fault on the SOAP path
details - details; if null the current stack trace and classname is inserted into the details.

AxisFault

protected AxisFault(java.lang.Exception target)
Wrap an AxisFault around an existing Exception - this is private to force everyone to use makeFault() above, which sanity-checks us.

AxisFault

public AxisFault(java.lang.String message)
create a simple axis fault from the message. Classname and stack trace go into the fault details.
Parameters:
message -  

AxisFault

public AxisFault()
No-arg constructor for building one from an XML stream.

AxisFault

public AxisFault(java.lang.String message,
                 java.lang.Throwable t)
create a fault from any throwable; When faulting a throwable (as opposed to an exception), stack trace information does not go into the fault.
Parameters:
message - any extra text to with the fault
t - whatever is to be turned into a fault
Method Detail

makeFault

public static AxisFault makeFault(java.lang.Exception 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.

dump

public void dump()
dump the fault info to the log at debug level

dumpToString

public java.lang.String dumpToString()
turn the fault and details into a string
Returns:
stringified fault details

setFaultCode

public void setFaultCode(QName code)
set the fault code
Parameters:
code - a new fault code

setFaultCodeAsString

public void setFaultCodeAsString(java.lang.String code)
set a fault code string that is turned into a qname in the axis namespace
Parameters:
code - fault code

getFaultCode

public QName getFaultCode()
get the fault code
Returns:
fault code QName or null

addFaultSubCodeAsString

public void addFaultSubCodeAsString(java.lang.String code)
This is new in SOAP 1.2, ignored in SOAP 1.1

addFaultSubCode

public void addFaultSubCode(QName code)
This is new in SOAP 1.2, ignored in SOAP 1.1

clearFaultSubCodes

public void clearFaultSubCodes()
This is new in SOAP 1.2, ignored in SOAP 1.1

getFaultSubCodes

public QName[] getFaultSubCodes()

setFaultString

public void setFaultString(java.lang.String str)
set a fault string;
Parameters:
str - new fault string; null is turned into ""

getFaultString

public java.lang.String getFaultString()
get the fault string; this will never be null but may be the empty string
Returns:
a fault string

setFaultReason

public void setFaultReason(java.lang.String str)
This is SOAP 1.2 equivalent of setFaultString(java.lang.String)

getFaultReason

public java.lang.String getFaultReason()
This is SOAP 1.2 equivalent of getFaultString()
Returns:
 

setFaultActor

public void setFaultActor(java.lang.String actor)
set the fault actor
Parameters:
actor - fault actor

getFaultActor

public java.lang.String getFaultActor()
get the fault actor
Returns:
actor or null

getFaultRole

public java.lang.String getFaultRole()
This is SOAP 1.2 equivalent of getFaultActor()
Returns:
 

setFaultRole

public void setFaultRole(java.lang.String role)
This is SOAP 1.2 equivalent of setFaultActor(java.lang.String)

getFaultNode

public java.lang.String getFaultNode()
This is new in SOAP 1.2
Returns:
 

setFaultNode

public void setFaultNode(java.lang.String node)
This is new in SOAP 1.2

setFaultDetail

public void setFaultDetail(org.w3c.dom.Element[] details)
the fault detail element to the arrary of details
Parameters:
details - list of detail elements, can be null

setFaultDetailString

public void setFaultDetailString(java.lang.String details)
turn a string containing an xml fragment into the fault details
Parameters:
details - XML fragment

addFaultDetailString

public void addFaultDetailString(java.lang.String detail)
parse an XML fragment and add it as a single element in the fault detail xml
Parameters:
detail - XML fragment

getFaultDetails

public org.w3c.dom.Element[] getFaultDetails()
get all the fault details
Returns:
an array of fault details, or null for none

output

public void output(SerializationContext context)
            throws java.lang.Exception
add this fault and any needed headers to the output context
Parameters:
context -  
Throws:
java.lang.Exception -  

toString

public java.lang.String toString()
string operator
Overrides:
toString in class java.lang.Throwable
Returns:
the current fault string; may be empty but never null

printStackTrace

public void printStackTrace(java.io.PrintStream ps)
The override of the base class method prints out the fault info before the stack trace
Overrides:
printStackTrace in class java.rmi.RemoteException
Parameters:
ps - where to print

printStackTrace

public void printStackTrace(java.io.PrintWriter pw)
The override of the base class method prints out the fault info before the stack trace
Overrides:
printStackTrace in class java.rmi.RemoteException
Parameters:
pw - where to print

addHeader

public void addHeader(SOAPHeaderElement header)
Add a SOAP header which should be serialized along with the fault.
Parameters:
header - a SOAPHeaderElement containing some fault-relevant stuff

clearHeaders

public void clearHeaders()
clear all fault headers

writeDetails

public void writeDetails(QName qname,
                         SerializationContext context)
                  throws java.io.IOException
Writes any exception data to the faultDetails This is for overriding; it is empty in the base AxisFault


Copyright © 2002 Apache XML Project. All Rights Reserved.