1 /*
2 * $Id: SOAPHeader.java,v 1.5.2.12 2004/11/17 13:59:28 vj135062 Exp $
3 * $Revision: 1.5.2.12 $
4 * $Date: 2004/11/17 13:59:28 $
5 */
6
7 /*
8 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 *
11 * This code is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 only, as
13 * published by the Free Software Foundation. Sun designates this
14 * particular file as subject to the "Classpath" exception as provided
15 * by Sun in the LICENSE file that accompanied this code.
16 *
17 * This code is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * version 2 for more details (a copy is included in the LICENSE file that
21 * accompanied this code).
22 *
23 * You should have received a copy of the GNU General Public License version
24 * 2 along with this work; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
28 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * have any questions.
30 */
31 package javax.xml.soap;
32
33 import java.util.Iterator;
34
35 import javax.xml.namespace.QName;
36
37 /**
38 * A representation of the SOAP header
39 * element. A SOAP header element consists of XML data that affects
40 * the way the application-specific content is processed by the message
41 * provider. For example, transaction semantics, authentication information,
42 * and so on, can be specified as the content of a <code>SOAPHeader</code>
43 * object.
44 * <P>
45 * A <code>SOAPEnvelope</code> object contains an empty
46 * <code>SOAPHeader</code> object by default. If the <code>SOAPHeader</code>
47 * object, which is optional, is not needed, it can be retrieved and deleted
48 * with the following line of code. The variable <i>se</i> is a
49 * <code>SOAPEnvelope</code> object.
50 * <PRE>
51 * se.getHeader().detachNode();
52 * </PRE>
53 *
54 * A <code>SOAPHeader</code> object is created with the <code>SOAPEnvelope</code>
55 * method <code>addHeader</code>. This method, which creates a new header and adds it
56 * to the envelope, may be called only after the existing header has been removed.
57 *
58 * <PRE>
59 * se.getHeader().detachNode();
60 * SOAPHeader sh = se.addHeader();
61 * </PRE>
62 * <P>
63 * A <code>SOAPHeader</code> object can have only <code>SOAPHeaderElement</code>
64 * objects as its immediate children. The method <code>addHeaderElement</code>
65 * creates a new <code>HeaderElement</code> object and adds it to the
66 * <code>SOAPHeader</code> object. In the following line of code, the
67 * argument to the method <code>addHeaderElement</code> is a <code>Name</code>
68 * object that is the name for the new <code>HeaderElement</code> object.
69 * <PRE>
70 * SOAPHeaderElement shElement = sh.addHeaderElement(name);
71 * </PRE>
72 *
73 * @see SOAPHeaderElement
74 */
75 public interface SOAPHeader extends SOAPElement {
76 /**
77 * Creates a new <code>SOAPHeaderElement</code> object initialized with the
78 * specified name and adds it to this <code>SOAPHeader</code> object.
79 *
80 * @param name a <code>Name</code> object with the name of the new
81 * <code>SOAPHeaderElement</code> object
82 * @return the new <code>SOAPHeaderElement</code> object that was
83 * inserted into this <code>SOAPHeader</code> object
84 * @exception SOAPException if a SOAP error occurs
85 * @see SOAPHeader#addHeaderElement(javax.xml.namespace.QName)
86 */
87 public SOAPHeaderElement addHeaderElement(Name name)
88 throws SOAPException;
89
90 /**
91 * Creates a new <code>SOAPHeaderElement</code> object initialized with the
92 * specified qname and adds it to this <code>SOAPHeader</code> object.
93 *
94 * @param qname a <code>QName</code> object with the qname of the new
95 * <code>SOAPHeaderElement</code> object
96 * @return the new <code>SOAPHeaderElement</code> object that was
97 * inserted into this <code>SOAPHeader</code> object
98 * @exception SOAPException if a SOAP error occurs
99 * @see SOAPHeader#addHeaderElement(Name)
100 * @since SAAJ 1.3
101 */
102 public SOAPHeaderElement addHeaderElement(QName qname)
103 throws SOAPException;
104
105 /**
106 * Returns an <code>Iterator</code> over all the <code>SOAPHeaderElement</code> objects
107 * in this <code>SOAPHeader</code> object
108 * that have the specified <i>actor</i> and that have a MustUnderstand attribute
109 * whose value is equivalent to <code>true</code>.
110 * <p>
111 * In SOAP 1.2 the <i>env:actor</i> attribute is replaced by the <i>env:role</i>
112 * attribute, but with essentially the same semantics.
113 *
114 * @param actor a <code>String</code> giving the URI of the <code>actor</code> / <code>role</code>
115 * for which to search
116 * @return an <code>Iterator</code> object over all the
117 * <code>SOAPHeaderElement</code> objects that contain the specified
118 * <code>actor</code> / <code>role</code> and are marked as MustUnderstand
119 * @see #examineHeaderElements
120 * @see #extractHeaderElements
121 * @see SOAPConstants#URI_SOAP_ACTOR_NEXT
122 *
123 * @since SAAJ 1.2
124 */
125 public Iterator examineMustUnderstandHeaderElements(String actor);
126
127 /**
128 * Returns an <code>Iterator</code> over all the <code>SOAPHeaderElement</code> objects
129 * in this <code>SOAPHeader</code> object
130 * that have the specified <i>actor</i>.
131 *
132 * An <i>actor</i> is a global attribute that indicates the intermediate
133 * parties that should process a message before it reaches its ultimate
134 * receiver. An actor receives the message and processes it before sending
135 * it on to the next actor. The default actor is the ultimate intended
136 * recipient for the message, so if no actor attribute is included in a
137 * <code>SOAPHeader</code> object, it is sent to the ultimate receiver
138 * along with the message body.
139 * <p>
140 * In SOAP 1.2 the <i>env:actor</i> attribute is replaced by the <i>env:role</i>
141 * attribute, but with essentially the same semantics.
142 *
143 * @param actor a <code>String</code> giving the URI of the <code>actor</code> / <code>role</code>
144 * for which to search
145 * @return an <code>Iterator</code> object over all the
146 * <code>SOAPHeaderElement</code> objects that contain the specified
147 * <code>actor</code> / <code>role</code>
148 * @see #extractHeaderElements
149 * @see SOAPConstants#URI_SOAP_ACTOR_NEXT
150 */
151 public Iterator examineHeaderElements(String actor);
152
153 /**
154 * Returns an <code>Iterator</code> over all the <code>SOAPHeaderElement</code> objects
155 * in this <code>SOAPHeader</code> object
156 * that have the specified <i>actor</i> and detaches them
157 * from this <code>SOAPHeader</code> object.
158 * <P>
159 * This method allows an actor to process the parts of the
160 * <code>SOAPHeader</code> object that apply to it and to remove
161 * them before passing the message on to the next actor.
162 * <p>
163 * In SOAP 1.2 the <i>env:actor</i> attribute is replaced by the <i>env:role</i>
164 * attribute, but with essentially the same semantics.
165 *
166 * @param actor a <code>String</code> giving the URI of the <code>actor</code> / <code>role</code>
167 * for which to search
168 * @return an <code>Iterator</code> object over all the
169 * <code>SOAPHeaderElement</code> objects that contain the specified
170 * <code>actor</code> / <code>role</code>
171 *
172 * @see #examineHeaderElements
173 * @see SOAPConstants#URI_SOAP_ACTOR_NEXT
174 */
175 public Iterator extractHeaderElements(String actor);
176
177 /**
178 * Creates a new NotUnderstood <code>SOAPHeaderElement</code> object initialized
179 * with the specified name and adds it to this <code>SOAPHeader</code> object.
180 * This operation is supported only by SOAP 1.2.
181 *
182 * @param name a <code>QName</code> object with the name of the
183 * <code>SOAPHeaderElement</code> object that was not understood.
184 * @return the new <code>SOAPHeaderElement</code> object that was
185 * inserted into this <code>SOAPHeader</code> object
186 * @exception SOAPException if a SOAP error occurs.
187 * @exception UnsupportedOperationException if this is a SOAP 1.1 Header.
188 * @since SAAJ 1.3
189 */
190 public SOAPHeaderElement addNotUnderstoodHeaderElement(QName name)
191 throws SOAPException;
192
193 /**
194 * Creates a new Upgrade <code>SOAPHeaderElement</code> object initialized
195 * with the specified List of supported SOAP URIs and adds it to this
196 * <code>SOAPHeader</code> object.
197 * This operation is supported on both SOAP 1.1 and SOAP 1.2 header.
198 *
199 * @param supportedSOAPURIs an <code>Iterator</code> object with the URIs of SOAP
200 * versions supported.
201 * @return the new <code>SOAPHeaderElement</code> object that was
202 * inserted into this <code>SOAPHeader</code> object
203 * @exception SOAPException if a SOAP error occurs.
204 * @since SAAJ 1.3
205 */
206 public SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSOAPURIs)
207 throws SOAPException;
208
209 /**
210 * Creates a new Upgrade <code>SOAPHeaderElement</code> object initialized
211 * with the specified array of supported SOAP URIs and adds it to this
212 * <code>SOAPHeader</code> object.
213 * This operation is supported on both SOAP 1.1 and SOAP 1.2 header.
214 *
215 * @param supportedSoapUris an array of the URIs of SOAP versions supported.
216 * @return the new <code>SOAPHeaderElement</code> object that was
217 * inserted into this <code>SOAPHeader</code> object
218 * @exception SOAPException if a SOAP error occurs.
219 * @since SAAJ 1.3
220 */
221 public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris)
222 throws SOAPException;
223
224 /**
225 * Creates a new Upgrade <code>SOAPHeaderElement</code> object initialized
226 * with the specified supported SOAP URI and adds it to this
227 * <code>SOAPHeader</code> object.
228 * This operation is supported on both SOAP 1.1 and SOAP 1.2 header.
229 *
230 * @param supportedSoapUri the URI of SOAP the version that is supported.
231 * @return the new <code>SOAPHeaderElement</code> object that was
232 * inserted into this <code>SOAPHeader</code> object
233 * @exception SOAPException if a SOAP error occurs.
234 * @since SAAJ 1.3
235 */
236 public SOAPHeaderElement addUpgradeHeaderElement(String supportedSoapUri)
237 throws SOAPException;
238
239 /**
240 * Returns an <code>Iterator</code> over all the <code>SOAPHeaderElement</code> objects
241 * in this <code>SOAPHeader</code> object.
242 *
243 * @return an <code>Iterator</code> object over all the
244 * <code>SOAPHeaderElement</code> objects contained by this
245 * <code>SOAPHeader</code>
246 * @see #extractAllHeaderElements
247 *
248 * @since SAAJ 1.2
249 */
250 public Iterator examineAllHeaderElements();
251
252 /**
253 * Returns an <code>Iterator</code> over all the <code>SOAPHeaderElement</code> objects
254 * in this <code>SOAPHeader</code> object and detaches them
255 * from this <code>SOAPHeader</code> object.
256 *
257 * @return an <code>Iterator</code> object over all the
258 * <code>SOAPHeaderElement</code> objects contained by this
259 * <code>SOAPHeader</code>
260 *
261 * @see #examineAllHeaderElements
262 *
263 * @since SAAJ 1.2
264 */
265 public Iterator extractAllHeaderElements();
266
267 }