Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPFault.java
38890 views
/*1* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.soap;2627import java.util.Iterator;28import java.util.Locale;2930import javax.xml.namespace.QName;3132/**33* An element in the <code>SOAPBody</code> object that contains34* error and/or status information. This information may relate to35* errors in the <code>SOAPMessage</code> object or to problems36* that are not related to the content in the message itself. Problems37* not related to the message itself are generally errors in38* processing, such as the inability to communicate with an upstream39* server.40* <P>41* Depending on the <code>protocol</code> specified while creating the42* <code>MessageFactory</code> instance, a <code>SOAPFault</code> has43* sub-elements as defined in the SOAP 1.1/SOAP 1.2 specification.44*/45public interface SOAPFault extends SOAPBodyElement {4647/**48* Sets this <code>SOAPFault</code> object with the given fault code.49*50* <P> Fault codes, which give information about the fault, are defined51* in the SOAP 1.1 specification. A fault code is mandatory and must52* be of type <code>Name</code>. This method provides a convenient53* way to set a fault code. For example,54*55* <PRE>56* SOAPEnvelope se = ...;57* // Create a qualified name in the SOAP namespace with a localName58* // of "Client". Note that prefix parameter is optional and is null59* // here which causes the implementation to use an appropriate prefix.60* Name qname = se.createName("Client", null,61* SOAPConstants.URI_NS_SOAP_ENVELOPE);62* SOAPFault fault = ...;63* fault.setFaultCode(qname);64* </PRE>65* It is preferable to use this method over {@link #setFaultCode(String)}.66*67* @param faultCodeQName a <code>Name</code> object giving the fault68* code to be set. It must be namespace qualified.69* @see #getFaultCodeAsName70*71* @exception SOAPException if there was an error in adding the72* <i>faultcode</i> element to the underlying XML tree.73*74* @since SAAJ 1.275*/76public void setFaultCode(Name faultCodeQName) throws SOAPException;7778/**79* Sets this <code>SOAPFault</code> object with the given fault code.80*81* It is preferable to use this method over {@link #setFaultCode(Name)}.82*83* @param faultCodeQName a <code>QName</code> object giving the fault84* code to be set. It must be namespace qualified.85* @see #getFaultCodeAsQName86*87* @exception SOAPException if there was an error in adding the88* <code>faultcode</code> element to the underlying XML tree.89*90* @see #setFaultCode(Name)91* @see #getFaultCodeAsQName()92*93* @since SAAJ 1.394*/95public void setFaultCode(QName faultCodeQName) throws SOAPException;9697/**98* Sets this <code>SOAPFault</code> object with the give fault code.99* <P>100* Fault codes, which given information about the fault, are defined in101* the SOAP 1.1 specification. This element is mandatory in SOAP 1.1.102* Because the fault code is required to be a QName it is preferable to103* use the {@link #setFaultCode(Name)} form of this method.104*105* @param faultCode a <code>String</code> giving the fault code to be set.106* It must be of the form "prefix:localName" where the prefix has107* been defined in a namespace declaration.108* @see #setFaultCode(Name)109* @see #getFaultCode110* @see SOAPElement#addNamespaceDeclaration111*112* @exception SOAPException if there was an error in adding the113* <code>faultCode</code> to the underlying XML tree.114*/115public void setFaultCode(String faultCode) throws SOAPException;116117/**118* Gets the mandatory SOAP 1.1 fault code for this119* <code>SOAPFault</code> object as a SAAJ <code>Name</code> object.120* The SOAP 1.1 specification requires the value of the "faultcode"121* element to be of type QName. This method returns the content of the122* element as a QName in the form of a SAAJ Name object. This method123* should be used instead of the <code>getFaultCode</code> method since124* it allows applications to easily access the namespace name without125* additional parsing.126*127* @return a <code>Name</code> representing the faultcode128* @see #setFaultCode(Name)129*130* @since SAAJ 1.2131*/132public Name getFaultCodeAsName();133134135/**136* Gets the fault code for this137* <code>SOAPFault</code> object as a <code>QName</code> object.138*139* @return a <code>QName</code> representing the faultcode140*141* @see #setFaultCode(QName)142*143* @since SAAJ 1.3144*/145public QName getFaultCodeAsQName();146147/**148* Gets the Subcodes for this <code>SOAPFault</code> as an iterator over149* <code>QNames</code>.150*151* @return an <code>Iterator</code> that accesses a sequence of152* <code>QNames</code>. This <code>Iterator</code> should not support153* the optional <code>remove</code> method. The order in which the154* Subcodes are returned reflects the hierarchy of Subcodes present155* in the fault from top to bottom.156*157* @exception UnsupportedOperationException if this message does not158* support the SOAP 1.2 concept of Subcode.159*160* @since SAAJ 1.3161*/162public Iterator getFaultSubcodes();163164/**165* Removes any Subcodes that may be contained by this166* <code>SOAPFault</code>. Subsequent calls to167* <code>getFaultSubcodes</code> will return an empty iterator until a call168* to <code>appendFaultSubcode</code> is made.169*170* @exception UnsupportedOperationException if this message does not171* support the SOAP 1.2 concept of Subcode.172*173* @since SAAJ 1.3174*/175public void removeAllFaultSubcodes();176177/**178* Adds a Subcode to the end of the sequence of Subcodes contained by this179* <code>SOAPFault</code>. Subcodes, which were introduced in SOAP 1.2, are180* represented by a recursive sequence of subelements rooted in the181* mandatory Code subelement of a SOAP Fault.182*183* @param subcode a QName containing the Value of the Subcode.184*185* @exception SOAPException if there was an error in setting the Subcode186* @exception UnsupportedOperationException if this message does not187* support the SOAP 1.2 concept of Subcode.188*189* @since SAAJ 1.3190*/191public void appendFaultSubcode(QName subcode) throws SOAPException;192193/**194* Gets the fault code for this <code>SOAPFault</code> object.195*196* @return a <code>String</code> with the fault code197* @see #getFaultCodeAsName198* @see #setFaultCode199*/200public String getFaultCode();201202/**203* Sets this <code>SOAPFault</code> object with the given fault actor.204* <P>205* The fault actor is the recipient in the message path who caused the206* fault to happen.207* <P>208* If this <code>SOAPFault</code> supports SOAP 1.2 then this call is209* equivalent to {@link #setFaultRole(String)}210*211* @param faultActor a <code>String</code> identifying the actor that212* caused this <code>SOAPFault</code> object213* @see #getFaultActor214*215* @exception SOAPException if there was an error in adding the216* <code>faultActor</code> to the underlying XML tree.217*/218public void setFaultActor(String faultActor) throws SOAPException;219220/**221* Gets the fault actor for this <code>SOAPFault</code> object.222* <P>223* If this <code>SOAPFault</code> supports SOAP 1.2 then this call is224* equivalent to {@link #getFaultRole()}225*226* @return a <code>String</code> giving the actor in the message path227* that caused this <code>SOAPFault</code> object228* @see #setFaultActor229*/230public String getFaultActor();231232/**233* Sets the fault string for this <code>SOAPFault</code> object234* to the given string.235* <P>236* If this237* <code>SOAPFault</code> is part of a message that supports SOAP 1.2 then238* this call is equivalent to:239* <pre>240* addFaultReasonText(faultString, Locale.getDefault());241* </pre>242*243* @param faultString a <code>String</code> giving an explanation of244* the fault245* @see #getFaultString246*247* @exception SOAPException if there was an error in adding the248* <code>faultString</code> to the underlying XML tree.249*/250public void setFaultString(String faultString) throws SOAPException;251252/**253* Sets the fault string for this <code>SOAPFault</code> object254* to the given string and localized to the given locale.255* <P>256* If this257* <code>SOAPFault</code> is part of a message that supports SOAP 1.2 then258* this call is equivalent to:259* <pre>260* addFaultReasonText(faultString, locale);261* </pre>262*263* @param faultString a <code>String</code> giving an explanation of264* the fault265* @param locale a {@link java.util.Locale Locale} object indicating266* the native language of the <code>faultString</code>267* @see #getFaultString268*269* @exception SOAPException if there was an error in adding the270* <code>faultString</code> to the underlying XML tree.271*272* @since SAAJ 1.2273*/274public void setFaultString(String faultString, Locale locale)275throws SOAPException;276277/**278* Gets the fault string for this <code>SOAPFault</code> object.279* <P>280* If this281* <code>SOAPFault</code> is part of a message that supports SOAP 1.2 then282* this call is equivalent to:283* <pre>284* String reason = null;285* try {286* reason = (String) getFaultReasonTexts().next();287* } catch (SOAPException e) {}288* return reason;289* </pre>290*291* @return a <code>String</code> giving an explanation of292* the fault293* @see #setFaultString(String)294* @see #setFaultString(String, Locale)295*/296public String getFaultString();297298/**299* Gets the locale of the fault string for this <code>SOAPFault</code>300* object.301* <P>302* If this303* <code>SOAPFault</code> is part of a message that supports SOAP 1.2 then304* this call is equivalent to:305* <pre>306* Locale locale = null;307* try {308* locale = (Locale) getFaultReasonLocales().next();309* } catch (SOAPException e) {}310* return locale;311* </pre>312*313* @return a <code>Locale</code> object indicating the native language of314* the fault string or <code>null</code> if no locale was specified315* @see #setFaultString(String, Locale)316*317* @since SAAJ 1.2318*/319public Locale getFaultStringLocale();320321/**322* Returns true if this <code>SOAPFault</code> has a <code>Detail</code>323* subelement and false otherwise. Equivalent to324* <code>(getDetail()!=null)</code>.325*326* @return true if this <code>SOAPFault</code> has a <code>Detail</code>327* subelement and false otherwise.328*329* @since SAAJ 1.3330*/331public boolean hasDetail();332333/**334* Returns the optional detail element for this <code>SOAPFault</code>335* object.336* <P>337* A <code>Detail</code> object carries application-specific error338* information, the scope of the error information is restricted to339* faults in the <code>SOAPBodyElement</code> objects if this is a340* SOAP 1.1 Fault.341*342* @return a <code>Detail</code> object with application-specific343* error information if present, null otherwise344*/345public Detail getDetail();346347/**348* Creates an optional <code>Detail</code> object and sets it as the349* <code>Detail</code> object for this <code>SOAPFault</code>350* object.351* <P>352* It is illegal to add a detail when the fault already353* contains a detail. Therefore, this method should be called354* only after the existing detail has been removed.355*356* @return the new <code>Detail</code> object357*358* @exception SOAPException if this359* <code>SOAPFault</code> object already contains a360* valid <code>Detail</code> object361*/362public Detail addDetail() throws SOAPException;363364/**365* Returns an <code>Iterator</code> over a distinct sequence of366* <code>Locale</code>s for which there are associated Reason Text items.367* Any of these <code>Locale</code>s can be used in a call to368* <code>getFaultReasonText</code> in order to obtain a localized version369* of the Reason Text string.370*371* @return an <code>Iterator</code> over a sequence of <code>Locale</code>372* objects for which there are associated Reason Text items.373*374* @exception SOAPException if there was an error in retrieving375* the fault Reason locales.376* @exception UnsupportedOperationException if this message does not377* support the SOAP 1.2 concept of Fault Reason.378*379* @since SAAJ 1.3380*/381public Iterator getFaultReasonLocales() throws SOAPException;382383/**384* Returns an <code>Iterator</code> over a sequence of385* <code>String</code> objects containing all of the Reason Text items for386* this <code>SOAPFault</code>.387*388* @return an <code>Iterator</code> over env:Fault/env:Reason/env:Text items.389*390* @exception SOAPException if there was an error in retrieving391* the fault Reason texts.392* @exception UnsupportedOperationException if this message does not393* support the SOAP 1.2 concept of Fault Reason.394*395* @since SAAJ 1.3396*/397public Iterator getFaultReasonTexts() throws SOAPException;398399/**400* Returns the Reason Text associated with the given <code>Locale</code>.401* If more than one such Reason Text exists the first matching Text is402* returned403*404* @param locale -- the <code>Locale</code> for which a localized405* Reason Text is desired406*407* @return the Reason Text associated with <code>locale</code>408*409* @see #getFaultString410*411* @exception SOAPException if there was an error in retrieving412* the fault Reason text for the specified locale .413* @exception UnsupportedOperationException if this message does not414* support the SOAP 1.2 concept of Fault Reason.415*416* @since SAAJ 1.3417*/418public String getFaultReasonText(Locale locale) throws SOAPException;419420/**421* Appends or replaces a Reason Text item containing the specified422* text message and an <i>xml:lang</i> derived from423* <code>locale</code>. If a Reason Text item with this424* <i>xml:lang</i> already exists its text value will be replaced425* with <code>text</code>.426* The <code>locale</code> parameter should not be <code>null</code>427* <P>428* Code sample:429*430* <PRE>431* SOAPFault fault = ...;432* fault.addFaultReasonText("Version Mismatch", Locale.ENGLISH);433* </PRE>434*435* @param text -- reason message string436* @param locale -- Locale object representing the locale of the message437*438* @exception SOAPException if there was an error in adding the Reason text439* or the <code>locale</code> passed was <code>null</code>.440* @exception UnsupportedOperationException if this message does not441* support the SOAP 1.2 concept of Fault Reason.442*443* @since SAAJ 1.3444*/445public void addFaultReasonText(String text, java.util.Locale locale)446throws SOAPException;447448/**449* Returns the optional Node element value for this450* <code>SOAPFault</code> object. The Node element is451* optional in SOAP 1.2.452*453* @return Content of the env:Fault/env:Node element as a String454* or <code>null</code> if none455*456* @exception UnsupportedOperationException if this message does not457* support the SOAP 1.2 concept of Fault Node.458*459* @since SAAJ 1.3460*/461public String getFaultNode();462463/**464* Creates or replaces any existing Node element value for465* this <code>SOAPFault</code> object. The Node element466* is optional in SOAP 1.2.467*468* @exception SOAPException if there was an error in setting the469* Node for this <code>SOAPFault</code> object.470* @exception UnsupportedOperationException if this message does not471* support the SOAP 1.2 concept of Fault Node.472*473*474* @since SAAJ 1.3475*/476public void setFaultNode(String uri) throws SOAPException;477478/**479* Returns the optional Role element value for this480* <code>SOAPFault</code> object. The Role element is481* optional in SOAP 1.2.482*483* @return Content of the env:Fault/env:Role element as a String484* or <code>null</code> if none485*486* @exception UnsupportedOperationException if this message does not487* support the SOAP 1.2 concept of Fault Role.488*489* @since SAAJ 1.3490*/491public String getFaultRole();492493/**494* Creates or replaces any existing Role element value for495* this <code>SOAPFault</code> object. The Role element496* is optional in SOAP 1.2.497*498* @param uri - the URI of the Role499*500* @exception SOAPException if there was an error in setting the501* Role for this <code>SOAPFault</code> object.502*503* @exception UnsupportedOperationException if this message does not504* support the SOAP 1.2 concept of Fault Role.505*506* @since SAAJ 1.3507*/508public void setFaultRole(String uri) throws SOAPException;509510}511512513