An exception which maps cleanly to a SOAP fault.
This is a base class for exceptions which are mapped to faults.
Constructor: |
public AxisFault(String message) {
this.message = message;
addReason(message);
}
Parameters:
message - the human-readable text describing the fault
|
public AxisFault(SOAPFault fault) {
initializeValues(fault);
}
|
protected AxisFault(Throwable cause) {
this((cause != null)
? cause.getMessage()
: null, 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
|
public AxisFault(SOAPFault fault,
MessageContext faultCtx) {
initializeValues(fault);
faultMessageContext = faultCtx;
}
|
public AxisFault(String messageText,
String faultCode) {
this(messageText);
setFaultCode(faultCode);
}
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
|
public AxisFault(String messageText,
QName faultCode) {
this(messageText);
setFaultCode(faultCode);
}
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
|
public AxisFault(String message,
Throwable cause) {
super(message, cause);
if (message != null) {
addReason(message);
this.message = message;
}
}
Parameters:
message - this will appear as the Text in the Reason information item of SOAP Fault
cause - the embedded Throwable that caused this fault
|
public AxisFault(String message,
MessageContext faultMessageContext) {
this(message);
this.faultMessageContext = 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
|
public AxisFault(QName faultCode,
String faultReason,
Throwable cause) {
this(faultReason, cause);
setFaultCode(faultCode);
}
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
|
public AxisFault(String messageText,
QName faultCode,
Throwable cause) {
this(messageText, cause);
setFaultCode(faultCode);
}
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
|
public AxisFault(String message,
MessageContext faultMessageContext,
Throwable cause) {
super(message, cause);
this.faultMessageContext = faultMessageContext;
}
Parameters:
message -
faultMessageContext -
cause -
|
public AxisFault(String messageText,
String faultCode,
Throwable cause) {
this(messageText, cause);
setFaultCode(faultCode);
}
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
|
public AxisFault(QName faultCode,
List faultSubCodes,
String faultReason,
Throwable cause) {
this(faultReason, cause);
setFaultCode(faultCode);
setFaultSubCodes(faultSubCodes);
}
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
|
public AxisFault(QName faultCode,
String faultReason,
String faultNode,
String faultRole,
OMElement faultDetail) {
this(faultReason, faultCode);
this.faultNode = faultNode;
this.faultRole = faultRole;
setDetail(faultDetail);
}
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
|
public AxisFault(SOAPFaultCode soapFaultCode,
SOAPFaultReason soapFaultReason,
SOAPFaultNode soapFaultNode,
SOAPFaultRole soapFaultRole,
SOAPFaultDetail soapFaultDetail) {
initializeValues(soapFaultCode, soapFaultReason, soapFaultNode, soapFaultRole,
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
|
Method from org.apache.axis2.AxisFault Detail: |
public void addHeader(SOAPHeaderBlock header) {
headers.add(header);
}
Add a header to the list of fault headers |
public void addReason(String text) {
faultReasonList.add(new FaultReason(text, ""));
}
Add a reason for the fault in the empty "" language |
public void addReason(String text,
String language) {
faultReasonList.add(new FaultReason(text, language));
}
Add a reason for the fault |
public OMElement getDetail() {
return detail;
}
Get the current fault detail |
public String getFaultAction() {
return faultAction;
}
|
public QName getFaultCode() {
return faultCode;
}
|
public SOAPFaultCode getFaultCodeElement() {
return soapFaultCode;
}
|
public SOAPFaultDetail getFaultDetailElement() {
return soapFaultDetail;
}
|
public MessageContext getFaultMessageContext() {
return faultMessageContext;
}
Returns the MessageContext representation of the fault if the fault
was created by providing that. |
public String getFaultNode() {
return faultNode;
}
|
public SOAPFaultNode getFaultNodeElement() {
return soapFaultNode;
}
|
public SOAPFaultReason getFaultReasonElement() {
return soapFaultReason;
}
|
public String getFaultRole() {
return faultRole;
}
|
public SOAPFaultRole getFaultRoleElement() {
return soapFaultRole;
}
|
public List getFaultSubCodes() {
return faultSubCodes;
}
|
public int getFaultType() {
return faultType;
}
|
public String getMessage() {
return message;
}
Returns the detail message, including the message from the cause, if any, of this exception. |
public String getNodeURI() {
return nodeURI;
}
Get the faulting node uri.
SOAP1.2 |
public String getReason() {
if (faultReasonList.size() >= 1) {
return ((FaultReason) faultReasonList.get(0)).getText();
} else if (soapFaultReason != null) {
return soapFaultReason.getText();
}
return null;
}
Returns the first fault reason, if available. If not found, returns null. |
public ListIterator headerIterator() {
return headers.listIterator();
}
Iterate over all of the headers |
public List headers() {
return headers;
}
Get at the headers. Useful for java1.5 iteration. |
public static AxisFault makeFault(Throwable e) {
if (e instanceof InvocationTargetException) {
return makeFault(((InvocationTargetException) e).getTargetException());
} else if (e instanceof UndeclaredThrowableException) {
Throwable t = ((UndeclaredThrowableException) e).getCause();
if (t instanceof Exception) {
e = (Exception) t;
}
}
if (e instanceof AxisFault) {
return (AxisFault) e;
}
return new AxisFault(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. |
public void setDetail(OMElement detail) {
this.detail = detail;
}
Set the entire detail element of the fault |
public void setFaultAction(String faultAction) {
this.faultAction = faultAction;
}
Set the (OPTIONAL) action value for the fault message |
public void setFaultCode(QName soapFaultCode) {
this.faultCode = soapFaultCode;
}
|
public void setFaultCode(String soapFaultCode) {
// TODO: is it really safe to assume that the passed string is always the localpart?
// What if someone passes soapenv:Sender?
faultCode = new QName(soapFaultCode);
}
|
public void setFaultSubCodes(List faultSubCodes) {
this.faultSubCodes = faultSubCodes;
}
|
public void setFaultType(int faultType) {
this.faultType = faultType;
}
|
public void setNodeURI(String nodeURI) {
this.nodeURI = nodeURI;
}
Set the faulting node uri. (SOAP1.2) |