Top Description Methods
javax.xml.soap

public Interface SOAPFault

extends SOAPBodyElement
Imports
java.util.Iterator, .Locale, javax.xml.namespace.QName

An element in the SOAPBody object that contains error and/or status information. This information may relate to errors in the SOAPMessage object or to problems that are not related to the content in the message itself. Problems not related to the message itself are generally errors in processing, such as the inability to communicate with an upstream server.

Depending on the protocol specified while creating the MessageFactory instance, a SOAPFault has sub-elements as defined in the SOAP 1.1/SOAP 1.2 specification.

Since
1.6

Method Summary

Modifier and TypeMethod and Description
public Detail

Returns:

the new Detail object
addDetail
()

Creates an optional Detail object and sets it as the Detail object for this SOAPFault object.

public void
addFaultReasonText(String
-- reason message string
text
,
Locale
-- Locale object representing the locale of the message
locale
)

Appends or replaces a Reason Text item containing the specified text message and an xml:lang derived from locale.

public void
appendFaultSubcode(QName
a QName containing the Value of the Subcode.
subcode
)

Adds a Subcode to the end of the sequence of Subcodes contained by this SOAPFault.

public Detail

Returns:

a Detail object with application-specific error information if present, null otherwise
getDetail
()

Returns the optional detail element for this SOAPFault object.

public String

Returns:

a String giving the actor in the message path that caused this SOAPFault object
getFaultActor
()

Gets the fault actor for this SOAPFault object.

public String

Returns:

a String with the fault code
getFaultCode
()

Gets the fault code for this SOAPFault object.

public Name

Returns:

a Name representing the faultcode
getFaultCodeAsName
()

Gets the mandatory SOAP 1.1 fault code for this SOAPFault object as a SAAJ Name object.

public QName

Returns:

a QName representing the faultcode
getFaultCodeAsQName
()

Gets the fault code for this SOAPFault object as a QName object.

public String

Returns:

Content of the env:Fault/env:Node element as a String or null if none
getFaultNode
()

Returns the optional Node element value for this SOAPFault object.

public Iterator<Locale>

Returns:

an Iterator over a sequence of Locale objects for which there are associated Reason Text items.
getFaultReasonLocales
()

Returns an Iterator over a distinct sequence of Locales for which there are associated Reason Text items.

public String

Returns:

the Reason Text associated with locale
getFaultReasonText
(Locale
-- the Locale for which a localized Reason Text is desired
locale
)

Returns the Reason Text associated with the given Locale.

public Iterator<String>

Returns:

an Iterator over env:Fault/env:Reason/env:Text items.
getFaultReasonTexts
()

Returns an Iterator over a sequence of String objects containing all of the Reason Text items for this SOAPFault.

public String

Returns:

Content of the env:Fault/env:Role element as a String or null if none
getFaultRole
()

Returns the optional Role element value for this SOAPFault object.

public String

Returns:

a String giving an explanation of the fault
getFaultString
()

Gets the fault string for this SOAPFault object.

public Locale

Returns:

a Locale object indicating the native language of the fault string or null if no locale was specified
getFaultStringLocale
()

Gets the locale of the fault string for this SOAPFault object.

public Iterator<QName>

Returns:

an Iterator that accesses a sequence of QNames. This Iterator should not support the optional remove method. The order in which the Subcodes are returned reflects the hierarchy of Subcodes present in the fault from top to bottom.
getFaultSubcodes
()

Gets the Subcodes for this SOAPFault as an iterator over QNames.

public boolean

Returns:

true if this SOAPFault has a Detail subelement and false otherwise.
hasDetail
()

Returns true if this SOAPFault has a Detail subelement and false otherwise.

public void
removeAllFaultSubcodes()

Removes any Subcodes that may be contained by this SOAPFault.

public void
setFaultActor(String
a String identifying the actor that caused this SOAPFault object
faultActor
)

Sets this SOAPFault object with the given fault actor.

public void
setFaultCode(Name
a Name object giving the fault code to be set. It must be namespace qualified.
faultCodeQName
)

Sets this SOAPFault object with the given fault code.

public void
setFaultCode(QName
a QName object giving the fault code to be set. It must be namespace qualified.
faultCodeQName
)

Sets this SOAPFault object with the given fault code.

public void
setFaultCode(String
a String giving the fault code to be set. It must be of the form "prefix:localName" where the prefix has been defined in a namespace declaration.
faultCode
)

Sets this SOAPFault object with the give fault code.

public void
setFaultNode(String
the URI of the Node
uri
)

Creates or replaces any existing Node element value for this SOAPFault object.

public void
setFaultRole(String
the URI of the Role
uri
)

Creates or replaces any existing Role element value for this SOAPFault object.

public void
setFaultString(String
a String giving an explanation of the fault
faultString
)

Sets the fault string for this SOAPFault object to the given string.

public void
setFaultString(String
a String giving an explanation of the fault
faultString
,
Locale
a Locale object indicating the native language of the faultString
locale
)

Sets the fault string for this SOAPFault object to the given string and localized to the given locale.

Method Detail

addDetailback to summary
public Detail addDetail() throws SOAPException

Creates an optional Detail object and sets it as the Detail object for this SOAPFault object.

It is illegal to add a detail when the fault already contains a detail. Therefore, this method should be called only after the existing detail has been removed.

Returns:Detail

the new Detail object

Exceptions
SOAPException:
if this SOAPFault object already contains a valid Detail object
addFaultReasonTextback to summary
public void addFaultReasonText(String text, Locale locale) throws SOAPException

Appends or replaces a Reason Text item containing the specified text message and an xml:lang derived from locale. If a Reason Text item with this xml:lang already exists its text value will be replaced with text. The locale parameter should not be null

Code sample:

SOAPFault fault = ...;
fault.addFaultReasonText("Version Mismatch", Locale.ENGLISH);
Parameters
text:String

-- reason message string

locale:Locale

-- Locale object representing the locale of the message

Exceptions
SOAPException:
if there was an error in adding the Reason text or the locale passed was null.
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Reason.
Since
1.6, SAAJ 1.3
appendFaultSubcodeback to summary
public void appendFaultSubcode(QName subcode) throws SOAPException

Adds a Subcode to the end of the sequence of Subcodes contained by this SOAPFault. Subcodes, which were introduced in SOAP 1.2, are represented by a recursive sequence of subelements rooted in the mandatory Code subelement of a SOAP Fault.

Parameters
subcode:QName

a QName containing the Value of the Subcode.

Exceptions
SOAPException:
if there was an error in setting the Subcode
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Subcode.
Since
1.6, SAAJ 1.3
getDetailback to summary
public Detail getDetail()

Returns the optional detail element for this SOAPFault object.

A Detail object carries application-specific error information, the scope of the error information is restricted to faults in the SOAPBodyElement objects if this is a SOAP 1.1 Fault.

Returns:Detail

a Detail object with application-specific error information if present, null otherwise

getFaultActorback to summary
public String getFaultActor()

Gets the fault actor for this SOAPFault object.

If this SOAPFault supports SOAP 1.2 then this call is equivalent to getFaultRole()

Returns:String

a String giving the actor in the message path that caused this SOAPFault object

See Also
setFaultActor
getFaultCodeback to summary
public String getFaultCode()

Gets the fault code for this SOAPFault object.

Returns:String

a String with the fault code

See Also
getFaultCodeAsName, setFaultCode
getFaultCodeAsNameback to summary
public Name getFaultCodeAsName()

Gets the mandatory SOAP 1.1 fault code for this SOAPFault object as a SAAJ Name object. The SOAP 1.1 specification requires the value of the "faultcode" element to be of type QName. This method returns the content of the element as a QName in the form of a SAAJ Name object. This method should be used instead of the getFaultCode method since it allows applications to easily access the namespace name without additional parsing.

Returns:Name

a Name representing the faultcode

Since
1.6, SAAJ 1.2
See Also
setFaultCode(Name)
getFaultCodeAsQNameback to summary
public QName getFaultCodeAsQName()

Gets the fault code for this SOAPFault object as a QName object.

Returns:QName

a QName representing the faultcode

Since
1.6, SAAJ 1.3
See Also
setFaultCode(QName)
getFaultNodeback to summary
public String getFaultNode()

Returns the optional Node element value for this SOAPFault object. The Node element is optional in SOAP 1.2.

Returns:String

Content of the env:Fault/env:Node element as a String or null if none

Exceptions
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Node.
Since
1.6, SAAJ 1.3
getFaultReasonLocalesback to summary
public Iterator<Locale> getFaultReasonLocales() throws SOAPException

Returns an Iterator over a distinct sequence of Locales for which there are associated Reason Text items. Any of these Locales can be used in a call to getFaultReasonText in order to obtain a localized version of the Reason Text string.

Returns:Iterator<Locale>

an Iterator over a sequence of Locale objects for which there are associated Reason Text items.

Exceptions
SOAPException:
if there was an error in retrieving the fault Reason locales.
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Reason.
Since
1.6, SAAJ 1.3
getFaultReasonTextback to summary
public String getFaultReasonText(Locale locale) throws SOAPException

Returns the Reason Text associated with the given Locale. If more than one such Reason Text exists the first matching Text is returned

Parameters
locale:Locale

-- the Locale for which a localized Reason Text is desired

Returns:String

the Reason Text associated with locale

Exceptions
SOAPException:
if there was an error in retrieving the fault Reason text for the specified locale .
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Reason.
Since
1.6, SAAJ 1.3
See Also
getFaultString
getFaultReasonTextsback to summary
public Iterator<String> getFaultReasonTexts() throws SOAPException

Returns an Iterator over a sequence of String objects containing all of the Reason Text items for this SOAPFault.

Returns:Iterator<String>

an Iterator over env:Fault/env:Reason/env:Text items.

Exceptions
SOAPException:
if there was an error in retrieving the fault Reason texts.
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Reason.
Since
1.6, SAAJ 1.3
getFaultRoleback to summary
public String getFaultRole()

Returns the optional Role element value for this SOAPFault object. The Role element is optional in SOAP 1.2.

Returns:String

Content of the env:Fault/env:Role element as a String or null if none

Exceptions
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Role.
Since
1.6, SAAJ 1.3
getFaultStringback to summary
public String getFaultString()

Gets the fault string for this SOAPFault object.

If this SOAPFault is part of a message that supports SOAP 1.2 then this call is equivalent to:

String reason = null;
   try {
       reason = (String) getFaultReasonTexts().next();
   } catch (SOAPException e) {}
   return reason;
Returns:String

a String giving an explanation of the fault

See Also
setFaultString(String), setFaultString(String, Locale)
getFaultStringLocaleback to summary
public Locale getFaultStringLocale()

Gets the locale of the fault string for this SOAPFault object.

If this SOAPFault is part of a message that supports SOAP 1.2 then this call is equivalent to:

Locale locale = null;
   try {
       locale = (Locale) getFaultReasonLocales().next();
   } catch (SOAPException e) {}
   return locale;
Returns:Locale

a Locale object indicating the native language of the fault string or null if no locale was specified

Since
1.6, SAAJ 1.2
See Also
setFaultString(String, Locale)
getFaultSubcodesback to summary
public Iterator<QName> getFaultSubcodes()

Gets the Subcodes for this SOAPFault as an iterator over QNames.

Returns:Iterator<QName>

an Iterator that accesses a sequence of QNames. This Iterator should not support the optional remove method. The order in which the Subcodes are returned reflects the hierarchy of Subcodes present in the fault from top to bottom.

Exceptions
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Subcode.
Since
1.6, SAAJ 1.3
hasDetailback to summary
public boolean hasDetail()

Returns true if this SOAPFault has a Detail subelement and false otherwise. Equivalent to (getDetail()!=null).

Returns:boolean

true if this SOAPFault has a Detail subelement and false otherwise.

Since
1.6, SAAJ 1.3
removeAllFaultSubcodesback to summary
public void removeAllFaultSubcodes()

Removes any Subcodes that may be contained by this SOAPFault. Subsequent calls to getFaultSubcodes will return an empty iterator until a call to appendFaultSubcode is made.

Exceptions
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Subcode.
Since
1.6, SAAJ 1.3
setFaultActorback to summary
public void setFaultActor(String faultActor) throws SOAPException

Sets this SOAPFault object with the given fault actor.

The fault actor is the recipient in the message path who caused the fault to happen.

If this SOAPFault supports SOAP 1.2 then this call is equivalent to setFaultRole(String)

Parameters
faultActor:String

a String identifying the actor that caused this SOAPFault object

Exceptions
SOAPException:
if there was an error in adding the faultActor to the underlying XML tree.
See Also
getFaultActor
setFaultCodeback to summary
public void setFaultCode(Name faultCodeQName) throws SOAPException

Sets this SOAPFault object with the given fault code.

Fault codes, which give information about the fault, are defined in the SOAP 1.1 specification. A fault code is mandatory and must be of type Name. This method provides a convenient way to set a fault code. For example,

SOAPEnvelope se = ...;
// Create a qualified name in the SOAP namespace with a localName
// of "Client". Note that prefix parameter is optional and is null
// here which causes the implementation to use an appropriate prefix.
Name qname = se.createName("Client", null,
                           SOAPConstants.URI_NS_SOAP_ENVELOPE);
SOAPFault fault = ...;
fault.setFaultCode(qname);
It is preferable to use this method over setFaultCode(String).
Parameters
faultCodeQName:Name

a Name object giving the fault code to be set. It must be namespace qualified.

Exceptions
SOAPException:
if there was an error in adding the faultcode element to the underlying XML tree.
Since
1.6, SAAJ 1.2
See Also
getFaultCodeAsName
setFaultCodeback to summary
public void setFaultCode(QName faultCodeQName) throws SOAPException

Sets this SOAPFault object with the given fault code. It is preferable to use this method over setFaultCode(Name).

Parameters
faultCodeQName:QName

a QName object giving the fault code to be set. It must be namespace qualified.

Exceptions
SOAPException:
if there was an error in adding the faultcode element to the underlying XML tree.
Since
1.6, SAAJ 1.3
See Also
getFaultCodeAsQName, setFaultCode(Name), getFaultCodeAsQName()
setFaultCodeback to summary
public void setFaultCode(String faultCode) throws SOAPException

Sets this SOAPFault object with the give fault code.

Fault codes, which given information about the fault, are defined in the SOAP 1.1 specification. This element is mandatory in SOAP 1.1. Because the fault code is required to be a QName it is preferable to use the setFaultCode(Name) form of this method.

Parameters
faultCode:String

a String giving the fault code to be set. It must be of the form "prefix:localName" where the prefix has been defined in a namespace declaration.

Exceptions
SOAPException:
if there was an error in adding the faultCode to the underlying XML tree.
See Also
setFaultCode(Name), getFaultCode, SOAPElement#addNamespaceDeclaration
setFaultNodeback to summary
public void setFaultNode(String uri) throws SOAPException

Creates or replaces any existing Node element value for this SOAPFault object. The Node element is optional in SOAP 1.2.

Parameters
uri:String

the URI of the Node

Exceptions
SOAPException:
if there was an error in setting the Node for this SOAPFault object.
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Node.
Since
1.6, SAAJ 1.3
setFaultRoleback to summary
public void setFaultRole(String uri) throws SOAPException

Creates or replaces any existing Role element value for this SOAPFault object. The Role element is optional in SOAP 1.2.

Parameters
uri:String

the URI of the Role

Exceptions
SOAPException:
if there was an error in setting the Role for this SOAPFault object.
UnsupportedOperationException:
if this message does not support the SOAP 1.2 concept of Fault Role.
Since
1.6, SAAJ 1.3
setFaultStringback to summary
public void setFaultString(String faultString) throws SOAPException

Sets the fault string for this SOAPFault object to the given string.

If this SOAPFault is part of a message that supports SOAP 1.2 then this call is equivalent to:

addFaultReasonText(faultString, Locale.getDefault());
Parameters
faultString:String

a String giving an explanation of the fault

Exceptions
SOAPException:
if there was an error in adding the faultString to the underlying XML tree.
See Also
getFaultString
setFaultStringback to summary
public void setFaultString(String faultString, Locale locale) throws SOAPException

Sets the fault string for this SOAPFault object to the given string and localized to the given locale.

If this SOAPFault is part of a message that supports SOAP 1.2 then this call is equivalent to:

addFaultReasonText(faultString, locale);
Parameters
faultString:String

a String giving an explanation of the fault

locale:Locale

a Locale object indicating the native language of the faultString

Exceptions
SOAPException:
if there was an error in adding the faultString to the underlying XML tree.
Since
1.6, SAAJ 1.2
See Also
getFaultString