Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/soap/SOAPBody.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.Locale;2829import org.w3c.dom.Document;3031import javax.xml.namespace.QName;3233/**34* An object that represents the contents of the SOAP body35* element in a SOAP message. A SOAP body element consists of XML data36* that affects the way the application-specific content is processed.37* <P>38* A <code>SOAPBody</code> object contains <code>SOAPBodyElement</code>39* objects, which have the content for the SOAP body.40* A <code>SOAPFault</code> object, which carries status and/or41* error information, is an example of a <code>SOAPBodyElement</code> object.42*43* @see SOAPFault44*/45public interface SOAPBody extends SOAPElement {4647/**48* Creates a new <code>SOAPFault</code> object and adds it to49* this <code>SOAPBody</code> object. The new <code>SOAPFault</code> will50* have default values set for the mandatory child elements. The type of51* the <code>SOAPFault</code> will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code>52* depending on the <code>protocol</code> specified while creating the53* <code>MessageFactory</code> instance.54* <p>55* A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>56* child element.57*58* @return the new <code>SOAPFault</code> object59* @exception SOAPException if there is a SOAP error60*/61public SOAPFault addFault() throws SOAPException;626364/**65* Creates a new <code>SOAPFault</code> object and adds it to66* this <code>SOAPBody</code> object. The type of the67* <code>SOAPFault</code> will be a SOAP 1.1 or a SOAP 1.268* <code>SOAPFault</code> depending on the <code>protocol</code>69* specified while creating the <code>MessageFactory</code> instance.70* <p>71* For SOAP 1.2 the <code>faultCode</code> parameter is the value of the72* <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter73* is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.174* the <code>faultCode</code> parameter is the value of the <code>faultcode</code>75* element and the <code>faultString</code> parameter is the value of the <code>faultstring</code>76* element.77* <p>78* A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>79* child element.80*81* @param faultCode a <code>Name</code> object giving the fault82* code to be set; must be one of the fault codes defined in the Version83* of SOAP specification in use84* @param faultString a <code>String</code> giving an explanation of85* the fault86* @param locale a {@link java.util.Locale} object indicating87* the native language of the <code>faultString</code>88* @return the new <code>SOAPFault</code> object89* @exception SOAPException if there is a SOAP error90* @see SOAPFault#setFaultCode91* @see SOAPFault#setFaultString92* @since SAAJ 1.293*/94public SOAPFault addFault(Name faultCode, String faultString, Locale locale) throws SOAPException;9596/**97* Creates a new <code>SOAPFault</code> object and adds it to this98* <code>SOAPBody</code> object. The type of the <code>SOAPFault</code>99* will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code> depending on100* the <code>protocol</code> specified while creating the <code>MessageFactory</code>101* instance.102* <p>103* For SOAP 1.2 the <code>faultCode</code> parameter is the value of the104* <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter105* is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.1106* the <code>faultCode</code> parameter is the value of the <code>faultcode</code>107* element and the <code>faultString</code> parameter is the value of the <code>faultstring</code>108* element.109* <p>110* A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>111* child element.112*113* @param faultCode114* a <code>QName</code> object giving the fault code to be115* set; must be one of the fault codes defined in the version116* of SOAP specification in use.117* @param faultString118* a <code>String</code> giving an explanation of the fault119* @param locale120* a {@link java.util.Locale Locale} object indicating the121* native language of the <code>faultString</code>122* @return the new <code>SOAPFault</code> object123* @exception SOAPException124* if there is a SOAP error125* @see SOAPFault#setFaultCode126* @see SOAPFault#setFaultString127* @see SOAPBody#addFault(Name faultCode, String faultString, Locale locale)128*129* @since SAAJ 1.3130*/131public SOAPFault addFault(QName faultCode, String faultString, Locale locale)132throws SOAPException;133134/**135* Creates a new <code>SOAPFault</code> object and adds it to this136* <code>SOAPBody</code> object. The type of the <code>SOAPFault</code>137* will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code> depending on138* the <code>protocol</code> specified while creating the <code>MessageFactory</code>139* instance.140* <p>141* For SOAP 1.2 the <code>faultCode</code> parameter is the value of the142* <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter143* is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.1144* the <code>faultCode</code> parameter is the value of the <i>faultcode</i>145* element and the <code>faultString</code> parameter is the value of the <i>faultstring</i>146* element.147* <p>148* In case of a SOAP 1.2 fault, the default value for the mandatory <code>xml:lang</code>149* attribute on the <i>Fault/Reason/Text</i> element will be set to150* <code>java.util.Locale.getDefault()</code>151* <p>152* A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>153* child element.154*155* @param faultCode156* a <code>Name</code> object giving the fault code to be set;157* must be one of the fault codes defined in the version of SOAP158* specification in use159* @param faultString160* a <code>String</code> giving an explanation of the fault161* @return the new <code>SOAPFault</code> object162* @exception SOAPException163* if there is a SOAP error164* @see SOAPFault#setFaultCode165* @see SOAPFault#setFaultString166* @since SAAJ 1.2167*/168public SOAPFault addFault(Name faultCode, String faultString)169throws SOAPException;170171/**172* Creates a new <code>SOAPFault</code> object and adds it to this <code>SOAPBody</code>173* object. The type of the <code>SOAPFault</code>174* will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code> depending on175* the <code>protocol</code> specified while creating the <code>MessageFactory</code>176* instance.177* <p>178* For SOAP 1.2 the <code>faultCode</code> parameter is the value of the179* <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter180* is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.1181* the <code>faultCode</code> parameter is the value of the <i>faultcode</i>182* element and the <code>faultString</code> parameter is the value of the <i>faultstring</i>183* element.184* <p>185* In case of a SOAP 1.2 fault, the default value for the mandatory <code>xml:lang</code>186* attribute on the <i>Fault/Reason/Text</i> element will be set to187* <code>java.util.Locale.getDefault()</code>188* <p>189* A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>190* child element191*192* @param faultCode193* a <code>QName</code> object giving the fault code to be194* set; must be one of the fault codes defined in the version195* of SOAP specification in use196* @param faultString197* a <code>String</code> giving an explanation of the fault198* @return the new <code>SOAPFault</code> object199* @exception SOAPException200* if there is a SOAP error201* @see SOAPFault#setFaultCode202* @see SOAPFault#setFaultString203* @see SOAPBody#addFault(Name faultCode, String faultString)204* @since SAAJ 1.3205*/206public SOAPFault addFault(QName faultCode, String faultString)207throws SOAPException;208209/**210* Indicates whether a <code>SOAPFault</code> object exists in this211* <code>SOAPBody</code> object.212*213* @return <code>true</code> if a <code>SOAPFault</code> object exists214* in this <code>SOAPBody</code> object; <code>false</code>215* otherwise216*/217public boolean hasFault();218219/**220* Returns the <code>SOAPFault</code> object in this <code>SOAPBody</code>221* object.222*223* @return the <code>SOAPFault</code> object in this <code>SOAPBody</code>224* object if present, null otherwise.225*/226public SOAPFault getFault();227228/**229* Creates a new <code>SOAPBodyElement</code> object with the specified230* name and adds it to this <code>SOAPBody</code> object.231*232* @param name233* a <code>Name</code> object with the name for the new <code>SOAPBodyElement</code>234* object235* @return the new <code>SOAPBodyElement</code> object236* @exception SOAPException237* if a SOAP error occurs238* @see SOAPBody#addBodyElement(javax.xml.namespace.QName)239*/240public SOAPBodyElement addBodyElement(Name name) throws SOAPException;241242243/**244* Creates a new <code>SOAPBodyElement</code> object with the specified245* QName and adds it to this <code>SOAPBody</code> object.246*247* @param qname248* a <code>QName</code> object with the qname for the new249* <code>SOAPBodyElement</code> object250* @return the new <code>SOAPBodyElement</code> object251* @exception SOAPException252* if a SOAP error occurs253* @see SOAPBody#addBodyElement(Name)254* @since SAAJ 1.3255*/256public SOAPBodyElement addBodyElement(QName qname) throws SOAPException;257258/**259* Adds the root node of the DOM <code>{@link org.w3c.dom.Document}</code>260* to this <code>SOAPBody</code> object.261* <p>262* Calling this method invalidates the <code>document</code> parameter.263* The client application should discard all references to this <code>Document</code>264* and its contents upon calling <code>addDocument</code>. The behavior265* of an application that continues to use such references is undefined.266*267* @param document268* the <code>Document</code> object whose root node will be269* added to this <code>SOAPBody</code>.270* @return the <code>SOAPBodyElement</code> that represents the root node271* that was added.272* @exception SOAPException273* if the <code>Document</code> cannot be added274* @since SAAJ 1.2275*/276public SOAPBodyElement addDocument(org.w3c.dom.Document document)277throws SOAPException;278279/**280* Creates a new DOM <code>{@link org.w3c.dom.Document}</code> and sets281* the first child of this <code>SOAPBody</code> as it's document282* element. The child <code>SOAPElement</code> is removed as part of the283* process.284*285* @return the <code>{@link org.w3c.dom.Document}</code> representation286* of the <code>SOAPBody</code> content.287*288* @exception SOAPException289* if there is not exactly one child <code>SOAPElement</code> of the <code>290* <code>SOAPBody</code>.291*292* @since SAAJ 1.3293*/294public org.w3c.dom.Document extractContentAsDocument()295throws SOAPException;296}297298299