001 /*
002 * $Id: SOAPBody.java,v 1.16 2005/04/05 22:28:13 mk125090 Exp $
003 * $Revision: 1.16 $
004 * $Date: 2005/04/05 22:28:13 $
005 */
006
007 /*
008 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
009 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
010 *
011 * This code is free software; you can redistribute it and/or modify it
012 * under the terms of the GNU General Public License version 2 only, as
013 * published by the Free Software Foundation. Sun designates this
014 * particular file as subject to the "Classpath" exception as provided
015 * by Sun in the LICENSE file that accompanied this code.
016 *
017 * This code is distributed in the hope that it will be useful, but WITHOUT
018 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
019 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
020 * version 2 for more details (a copy is included in the LICENSE file that
021 * accompanied this code).
022 *
023 * You should have received a copy of the GNU General Public License version
024 * 2 along with this work; if not, write to the Free Software Foundation,
025 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
026 *
027 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
028 * CA 95054 USA or visit www.sun.com if you need additional information or
029 * have any questions.
030 */
031 package javax.xml.soap;
032
033 import java.util.Locale;
034
035 import org.w3c.dom.Document;
036
037 import javax.xml.namespace.QName;
038
039 /**
040 * An object that represents the contents of the SOAP body
041 * element in a SOAP message. A SOAP body element consists of XML data
042 * that affects the way the application-specific content is processed.
043 * <P>
044 * A <code>SOAPBody</code> object contains <code>SOAPBodyElement</code>
045 * objects, which have the content for the SOAP body.
046 * A <code>SOAPFault</code> object, which carries status and/or
047 * error information, is an example of a <code>SOAPBodyElement</code> object.
048 *
049 * @see SOAPFault
050 */
051 public interface SOAPBody extends SOAPElement {
052
053 /**
054 * Creates a new <code>SOAPFault</code> object and adds it to
055 * this <code>SOAPBody</code> object. The new <code>SOAPFault</code> will
056 * have default values set for the mandatory child elements. The type of
057 * the <code>SOAPFault</code> will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code>
058 * depending on the <code>protocol</code> specified while creating the
059 * <code>MessageFactory</code> instance.
060 * <p>
061 * A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>
062 * child element.
063 *
064 * @return the new <code>SOAPFault</code> object
065 * @exception SOAPException if there is a SOAP error
066 */
067 public SOAPFault addFault() throws SOAPException;
068
069 /**
070 * Creates a new <code>SOAPFault</code> object and adds it to
071 * this <code>SOAPBody</code> object. The type of the
072 * <code>SOAPFault</code> will be a SOAP 1.1 or a SOAP 1.2
073 * <code>SOAPFault</code> depending on the <code>protocol</code>
074 * specified while creating the <code>MessageFactory</code> instance.
075 * <p>
076 * For SOAP 1.2 the <code>faultCode</code> parameter is the value of the
077 * <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter
078 * is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.1
079 * the <code>faultCode</code> parameter is the value of the <code>faultcode</code>
080 * element and the <code>faultString</code> parameter is the value of the <code>faultstring</code>
081 * element.
082 * <p>
083 * A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>
084 * child element.
085 *
086 * @param faultCode a <code>Name</code> object giving the fault
087 * code to be set; must be one of the fault codes defined in the Version
088 * of SOAP specification in use
089 * @param faultString a <code>String</code> giving an explanation of
090 * the fault
091 * @param locale a {@link java.util.Locale} object indicating
092 * the native language of the <code>faultString</code>
093 * @return the new <code>SOAPFault</code> object
094 * @exception SOAPException if there is a SOAP error
095 * @see SOAPFault#setFaultCode
096 * @see SOAPFault#setFaultString
097 * @since SAAJ 1.2
098 */
099 public SOAPFault addFault(Name faultCode, String faultString,
100 Locale locale) throws SOAPException;
101
102 /**
103 * Creates a new <code>SOAPFault</code> object and adds it to this
104 * <code>SOAPBody</code> object. The type of the <code>SOAPFault</code>
105 * will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code> depending on
106 * the <code>protocol</code> specified while creating the <code>MessageFactory</code>
107 * instance.
108 * <p>
109 * For SOAP 1.2 the <code>faultCode</code> parameter is the value of the
110 * <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter
111 * is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.1
112 * the <code>faultCode</code> parameter is the value of the <code>faultcode</code>
113 * element and the <code>faultString</code> parameter is the value of the <code>faultstring</code>
114 * element.
115 * <p>
116 * A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>
117 * child element.
118 *
119 * @param faultCode
120 * a <code>QName</code> object giving the fault code to be
121 * set; must be one of the fault codes defined in the version
122 * of SOAP specification in use.
123 * @param faultString
124 * a <code>String</code> giving an explanation of the fault
125 * @param locale
126 * a {@link java.util.Locale Locale} object indicating the
127 * native language of the <code>faultString</code>
128 * @return the new <code>SOAPFault</code> object
129 * @exception SOAPException
130 * if there is a SOAP error
131 * @see SOAPFault#setFaultCode
132 * @see SOAPFault#setFaultString
133 * @see SOAPBody#addFault(Name faultCode, String faultString, Locale locale)
134 *
135 * @since SAAJ 1.3
136 */
137 public SOAPFault addFault(QName faultCode, String faultString,
138 Locale locale) throws SOAPException;
139
140 /**
141 * Creates a new <code>SOAPFault</code> object and adds it to this
142 * <code>SOAPBody</code> object. The type of the <code>SOAPFault</code>
143 * will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code> depending on
144 * the <code>protocol</code> specified while creating the <code>MessageFactory</code>
145 * instance.
146 * <p>
147 * For SOAP 1.2 the <code>faultCode</code> parameter is the value of the
148 * <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter
149 * is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.1
150 * the <code>faultCode</code> parameter is the value of the <i>faultcode</i>
151 * element and the <code>faultString</code> parameter is the value of the <i>faultstring</i>
152 * element.
153 * <p>
154 * In case of a SOAP 1.2 fault, the default value for the mandatory <code>xml:lang</code>
155 * attribute on the <i>Fault/Reason/Text</i> element will be set to
156 * <code>java.util.Locale.getDefault()</code>
157 * <p>
158 * A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>
159 * child element.
160 *
161 * @param faultCode
162 * a <code>Name</code> object giving the fault code to be set;
163 * must be one of the fault codes defined in the version of SOAP
164 * specification in use
165 * @param faultString
166 * a <code>String</code> giving an explanation of the fault
167 * @return the new <code>SOAPFault</code> object
168 * @exception SOAPException
169 * if there is a SOAP error
170 * @see SOAPFault#setFaultCode
171 * @see SOAPFault#setFaultString
172 * @since SAAJ 1.2
173 */
174 public SOAPFault addFault(Name faultCode, String faultString)
175 throws SOAPException;
176
177 /**
178 * Creates a new <code>SOAPFault</code> object and adds it to this <code>SOAPBody</code>
179 * object. The type of the <code>SOAPFault</code>
180 * will be a SOAP 1.1 or a SOAP 1.2 <code>SOAPFault</code> depending on
181 * the <code>protocol</code> specified while creating the <code>MessageFactory</code>
182 * instance.
183 * <p>
184 * For SOAP 1.2 the <code>faultCode</code> parameter is the value of the
185 * <i>Fault/Code/Value</i> element and the <code>faultString</code> parameter
186 * is the value of the <i>Fault/Reason/Text</i> element. For SOAP 1.1
187 * the <code>faultCode</code> parameter is the value of the <i>faultcode</i>
188 * element and the <code>faultString</code> parameter is the value of the <i>faultstring</i>
189 * element.
190 * <p>
191 * In case of a SOAP 1.2 fault, the default value for the mandatory <code>xml:lang</code>
192 * attribute on the <i>Fault/Reason/Text</i> element will be set to
193 * <code>java.util.Locale.getDefault()</code>
194 * <p>
195 * A <code>SOAPBody</code> may contain at most one <code>SOAPFault</code>
196 * child element
197 *
198 * @param faultCode
199 * a <code>QName</code> object giving the fault code to be
200 * set; must be one of the fault codes defined in the version
201 * of SOAP specification in use
202 * @param faultString
203 * a <code>String</code> giving an explanation of the fault
204 * @return the new <code>SOAPFault</code> object
205 * @exception SOAPException
206 * if there is a SOAP error
207 * @see SOAPFault#setFaultCode
208 * @see SOAPFault#setFaultString
209 * @see SOAPBody#addFault(Name faultCode, String faultString)
210 * @since SAAJ 1.3
211 */
212 public SOAPFault addFault(QName faultCode, String faultString)
213 throws SOAPException;
214
215 /**
216 * Indicates whether a <code>SOAPFault</code> object exists in this
217 * <code>SOAPBody</code> object.
218 *
219 * @return <code>true</code> if a <code>SOAPFault</code> object exists
220 * in this <code>SOAPBody</code> object; <code>false</code>
221 * otherwise
222 */
223 public boolean hasFault();
224
225 /**
226 * Returns the <code>SOAPFault</code> object in this <code>SOAPBody</code>
227 * object.
228 *
229 * @return the <code>SOAPFault</code> object in this <code>SOAPBody</code>
230 * object if present, null otherwise.
231 */
232 public SOAPFault getFault();
233
234 /**
235 * Creates a new <code>SOAPBodyElement</code> object with the specified
236 * name and adds it to this <code>SOAPBody</code> object.
237 *
238 * @param name
239 * a <code>Name</code> object with the name for the new <code>SOAPBodyElement</code>
240 * object
241 * @return the new <code>SOAPBodyElement</code> object
242 * @exception SOAPException
243 * if a SOAP error occurs
244 * @see SOAPBody#addBodyElement(javax.xml.namespace.QName)
245 */
246 public SOAPBodyElement addBodyElement(Name name)
247 throws SOAPException;
248
249 /**
250 * Creates a new <code>SOAPBodyElement</code> object with the specified
251 * QName and adds it to this <code>SOAPBody</code> object.
252 *
253 * @param qname
254 * a <code>QName</code> object with the qname for the new
255 * <code>SOAPBodyElement</code> object
256 * @return the new <code>SOAPBodyElement</code> object
257 * @exception SOAPException
258 * if a SOAP error occurs
259 * @see SOAPBody#addBodyElement(Name)
260 * @since SAAJ 1.3
261 */
262 public SOAPBodyElement addBodyElement(QName qname)
263 throws SOAPException;
264
265 /**
266 * Adds the root node of the DOM <code>{@link org.w3c.dom.Document}</code>
267 * to this <code>SOAPBody</code> object.
268 * <p>
269 * Calling this method invalidates the <code>document</code> parameter.
270 * The client application should discard all references to this <code>Document</code>
271 * and its contents upon calling <code>addDocument</code>. The behavior
272 * of an application that continues to use such references is undefined.
273 *
274 * @param document
275 * the <code>Document</code> object whose root node will be
276 * added to this <code>SOAPBody</code>.
277 * @return the <code>SOAPBodyElement</code> that represents the root node
278 * that was added.
279 * @exception SOAPException
280 * if the <code>Document</code> cannot be added
281 * @since SAAJ 1.2
282 */
283 public SOAPBodyElement addDocument(org.w3c.dom.Document document)
284 throws SOAPException;
285
286 /**
287 * Creates a new DOM <code>{@link org.w3c.dom.Document}</code> and sets
288 * the first child of this <code>SOAPBody</code> as it's document
289 * element. The child <code>SOAPElement</code> is removed as part of the
290 * process.
291 *
292 * @return the <code>{@link org.w3c.dom.Document}</code> representation
293 * of the <code>SOAPBody</code> content.
294 *
295 * @exception SOAPException
296 * if there is not exactly one child <code>SOAPElement</code> of the
297 * <code>SOAPBody</code>.
298 *
299 * @since SAAJ 1.3
300 */
301 public org.w3c.dom.Document extractContentAsDocument()
302 throws SOAPException;
303 }
|