Package 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:
Serializable
- Direct Known Subclasses:
NoEndPointException
An exception which maps cleanly to a SOAP fault.
This is a base class for exceptions which are mapped to faults.
SOAP faults contain
- A fault string
- A fault code
- A fault actor
- Fault details; an xml tree of fault specific stuff
- Author:
- Doug Davis (dug@us.ibm.com), James Snell (jasnell@us.ibm.com), Steve Loughran
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected QNameprotected Vectorprotected ArrayListSOAP headers which should be serialized with the Fault.protected Stringprotected Stringprotected VectorSOAP1.2 addition: subcodes of faults; a Vector of QNamesprotected static org.apache.commons.logging.LogTheLogused by this class for all logging.Fields inherited from class java.rmi.RemoteException
detail -
Constructor Summary
ConstructorsModifierConstructorDescriptionNo-arg constructor for building one from an XML stream.protectedWrap an AxisFault around an existing Exception.create a simple axis fault from the message.Make a fault in theConstants.NS_URI_AXISnamespace.create a fault from any throwable; When faulting a throwable (as opposed to an exception), stack trace information does not go into the fault.Make a fault in any namespace.AxisFault(QName code, QName[] subcodes, String faultString, String actor, String node, Element[] details) Make a fault in any namespace. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFaultDetail(QName qname, String body) Create an element of the given qname and add it to the details.voidaddFaultDetail(Element detail) Append an element to the fault detail list.voidaddFaultDetailString(String detail) add a string tag to the fault details.voidaddFaultSubCode(QName code) Add a fault sub-code.voidAdd a fault sub-code with the local namecodeand namespaceConstants.NS_URI_AXIS.voidaddHeader(SOAPHeaderElement header) Add a SOAP header which should be serialized along with the fault.voidaddHostname(String hostname) add the hostname string.voidadd the hostname of the current system.voidClear the fault details list.voidClear all fault sub-codes.voidClear all fault headers.voiddump()Dump the fault info to the log at debug level.turn the fault and details into a string, with XML escaping.get the fault actorGet the fault codeQName.Element[]Get all the fault details.Get the fault node.This is SOAP 1.2 equivalent ofgetFaultString().This is SOAP 1.2 equivalent ofgetFaultActor().Get the fault string; this will never be null but may be the empty string.QName[]get the fault subcode list; only used in SOAP 1.2Get the SOAP headers associated with this fault.protected voidDo whatever is needed to create the fault subcodes data structure, if it is needed.lookupFaultDetail(QName qname) Find a fault detail element by its qname.static AxisFaultMake an AxisFault based on a passed Exception.voidoutput(SerializationContext context) Add this fault and any needed headers to the output context.voidThe override of the base class method prints out the fault info before the stack trace.voidThe override of the base class method prints out the fault info before the stack trace.booleanremoveFaultDetail(QName qname) Find and remove a specified fault detail element.voidstrip out the hostname on a message.voidsetFaultActor(String actor) Set the fault actor.voidsetFaultCode(String code) Deprecated.expect to see this go away after 1.1, use setFaultCodeAsString instead!voidsetFaultCode(QName code) Set the fault code.voidsetFaultCodeAsString(String code) set a fault code string that is turned into a qname in the SOAP 1.1 or 1.2 namespace, depending on the current contextvoidsetFaultDetail(Element[] details) Set the fault detail element to the arrary of details.voidsetFaultDetailString(String details) set the fault details to a string element.voidsetFaultNode(String node) Set the fault node.voidsetFaultReason(String str) This is SOAP 1.2 equivalent ofsetFaultString(java.lang.String).voidsetFaultRole(String role) This is SOAP 1.2 equivalent ofsetFaultActor(java.lang.String).voidsetFaultString(String str) Set a fault string.toString()Stringify this fault as the current fault string.voidwriteDetails(QName qname, SerializationContext context) Writes any exception data to the faultDetails.Methods inherited from class java.rmi.RemoteException
getCause, getMessageMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, setStackTrace
-
Field Details
-
log
protected static org.apache.commons.logging.Log logTheLogused by this class for all logging. -
faultCode
-
faultSubCode
SOAP1.2 addition: subcodes of faults; a Vector of QNames -
faultString
-
faultActor
-
faultDetails
-
faultNode
-
faultHeaders
SOAP headers which should be serialized with the Fault.
-
-
Constructor Details
-
AxisFault
Make a fault in theConstants.NS_URI_AXISnamespace.- Parameters:
code- fault code which will be passed into the Axis namespacefaultString- fault stringactor- fault actordetails- details; if null the current stack trace and classname is inserted into the details.
-
AxisFault
Make a fault in any namespace.- Parameters:
code- fault code which will be passed into the Axis namespacefaultString- fault stringactor- fault actordetails- details; if null the current stack trace and classname is inserted into the details.
-
AxisFault
public AxisFault(QName code, QName[] subcodes, String faultString, String actor, String node, Element[] details) Make a fault in any namespace.- Parameters:
code- fault code which will be passed into the Axis namespacesubcodes- fault subcodes which will be pased into the Axis namespacefaultString- fault stringactor- fault actor, same as fault role in SOAP 1.2node- which node caused the fault on the SOAP pathdetails- details; if null the current stack trace and classname is inserted into the details.- Since:
- axis1.1
-
AxisFault
Wrap an AxisFault around an existing Exception. This is private to force everyone to use makeFault() above, which sanity-checks us.- Parameters:
target- the targetException
-
AxisFault
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
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 faultt- whatever is to be turned into a fault
-
-
Method Details
-
makeFault
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- theExceptionto build a fault for- Returns:
- an
AxisFaultrepresentinge
-
clearFaultDetails
public void clearFaultDetails()Clear the fault details list. -
dump
public void dump()Dump the fault info to the log at debug level. -
dumpToString
turn the fault and details into a string, with XML escaping. subclassers: for security (cross-site-scripting) reasons, escape everything that could contain caller-supplied data.- Returns:
- stringified fault details
-
setFaultCode
Set the fault code.- Parameters:
code- a new fault code
-
setFaultCode
Deprecated.expect to see this go away after 1.1, use setFaultCodeAsString instead!Set the fault code (as a String).- Parameters:
code- a new fault code
-
setFaultCodeAsString
set a fault code string that is turned into a qname in the SOAP 1.1 or 1.2 namespace, depending on the current context- Parameters:
code- fault code
-
getFaultCode
Get the fault codeQName.- Returns:
- fault code QName or null if there is none yet.
-
addFaultSubCodeAsString
Add a fault sub-code with the local namecodeand namespaceConstants.NS_URI_AXIS. This is new in SOAP 1.2, ignored in SOAP 1.1- Parameters:
code- the local name of the code to add- Since:
- axis1.1
-
initFaultSubCodes
protected void initFaultSubCodes()Do whatever is needed to create the fault subcodes data structure, if it is needed. -
addFaultSubCode
Add a fault sub-code. This is new in SOAP 1.2, ignored in SOAP 1.1.- Parameters:
code- theQNameof the fault sub-code to add- Since:
- axis1.1
-
clearFaultSubCodes
public void clearFaultSubCodes()Clear all fault sub-codes. This is new in SOAP 1.2, ignored in SOAP 1.1.- Since:
- axis1.1
-
getFaultSubCodes
get the fault subcode list; only used in SOAP 1.2- Returns:
- null for no subcodes, or a QName array
- Since:
- axis1.1
-
setFaultString
Set a fault string.- Parameters:
str- new fault string; null is turned into ""
-
getFaultString
Get the fault string; this will never be null but may be the empty string.- Returns:
- a fault string
-
setFaultReason
This is SOAP 1.2 equivalent ofsetFaultString(java.lang.String).- Parameters:
str- the fault reason as aString- Since:
- axis1.1
-
getFaultReason
This is SOAP 1.2 equivalent ofgetFaultString().- Returns:
- the fault
String - Since:
- axis1.1
-
setFaultActor
Set the fault actor.- Parameters:
actor- fault actor
-
getFaultActor
get the fault actor- Returns:
- actor or null
-
getFaultRole
This is SOAP 1.2 equivalent ofgetFaultActor().- Returns:
- the name of the fault actor
- Since:
- axis1.1
-
setFaultRole
This is SOAP 1.2 equivalent ofsetFaultActor(java.lang.String).- Since:
- axis1.1
-
getFaultNode
Get the fault node. This is new in SOAP 1.2- Returns:
- Since:
- axis1.1
-
setFaultNode
Set the fault node. This is new in SOAP 1.2.- Parameters:
node- aStringrepresenting the fault node- Since:
- axis1.1
-
setFaultDetail
Set the fault detail element to the arrary of details.- Parameters:
details- list of detail elements, can be null
-
setFaultDetailString
set the fault details to a string element.- Parameters:
details- XML fragment
-
addFaultDetailString
add a string tag to the fault details.- Parameters:
detail- XML fragment
-
addFaultDetail
Append an element to the fault detail list.- Parameters:
detail- the new element to add- Since:
- Axis1.1
-
addFaultDetail
Create an element of the given qname and add it to the details.- Parameters:
qname- qname of the elementbody- string to use as body
-
getFaultDetails
Get all the fault details.- Returns:
- an array of fault details, or null for none
-
lookupFaultDetail
Find a fault detail element by its qname.- Parameters:
qname- name of the node to look for- Returns:
- the matching element or null
- Since:
- axis1.1
-
removeFaultDetail
Find and remove a specified fault detail element.- Parameters:
qname- qualified name of detail- Returns:
- true if it was found and removed, false otherwise
- Since:
- axis1.1
-
output
Add this fault and any needed headers to the output context.- Parameters:
context-- Throws:
Exception
-
toString
Stringify this fault as the current fault string. -
printStackTrace
The override of the base class method prints out the fault info before the stack trace.- Overrides:
printStackTracein classThrowable- Parameters:
ps- where to print
-
printStackTrace
The override of the base class method prints out the fault info before the stack trace.- Overrides:
printStackTracein classThrowable- Parameters:
pw- where to print
-
addHeader
Add a SOAP header which should be serialized along with the fault.- Parameters:
header- a SOAPHeaderElement containing some fault-relevant stuff
-
getHeaders
Get the SOAP headers associated with this fault.- Returns:
- an ArrayList containing any headers associated with this fault
-
clearHeaders
public void clearHeaders()Clear all fault headers. -
writeDetails
Writes any exception data to the faultDetails. This can be overridden (and is) by emitted exception clases. The base implementation will attempt to serialize exception data the fault was created from an Exception and a type mapping is found for it.- Parameters:
qname- theQNameto write this undercontext- theSerializationContextto write this fault to- Throws:
IOException- if we can't write ourselves for any reason
-
addHostnameIfNeeded
public void addHostnameIfNeeded()add the hostname of the current system. This is very useful for locating faults on a cluster.- Since:
- Axis1.2
-
addHostname
add the hostname string. If one already exists, remove it.- Parameters:
hostname- string name of a host- Since:
- Axis1.2
-
removeHostname
public void removeHostname()strip out the hostname on a message. This is useful for security reasons.
-