001 /*
002 * Copyright 2001-2004 The Apache Software Foundation.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package javax.xml.soap;
017
018 import java.util.Iterator;
019
020 /**
021 * <P>A representation of the SOAP header element. A SOAP header
022 * element consists of XML data that affects the way the
023 * application-specific content is processed by the message
024 * provider. For example, transaction semantics, authentication
025 * information, and so on, can be specified as the content of a
026 * <CODE>SOAPHeader</CODE> object.</P>
027 *
028 * <P>A <CODE>SOAPEnvelope</CODE> object contains an empty <CODE>
029 * SOAPHeader</CODE> object by default. If the <CODE>
030 * SOAPHeader</CODE> object, which is optional, is not needed, it
031 * can be retrieved and deleted with the following line of code.
032 * The variable <I>se</I> is a <CODE>SOAPEnvelope</CODE>
033 * object.</P>
034 * <PRE>
035 * se.getHeader().detachNode();
036 * </PRE>
037 * A <CODE>SOAPHeader</CODE> object is created with the <CODE>
038 * SOAPEnvelope</CODE> method <CODE>addHeader</CODE>. This method,
039 * which creates a new header and adds it to the envelope, may be
040 * called only after the existing header has been removed.
041 * <PRE>
042 * se.getHeader().detachNode();
043 * SOAPHeader sh = se.addHeader();
044 * </PRE>
045 *
046 * <P>A <CODE>SOAPHeader</CODE> object can have only <CODE>
047 * SOAPHeaderElement</CODE> objects as its immediate children. The
048 * method <CODE>addHeaderElement</CODE> creates a new <CODE>
049 * HeaderElement</CODE> object and adds it to the <CODE>
050 * SOAPHeader</CODE> object. In the following line of code, the
051 * argument to the method <CODE>addHeaderElement</CODE> is a
052 * <CODE>Name</CODE> object that is the name for the new <CODE>
053 * HeaderElement</CODE> object.</P>
054 * <PRE>
055 * SOAPHeaderElement shElement = sh.addHeaderElement(name);
056 * </PRE>
057 * @see SOAPHeaderElement SOAPHeaderElement
058 */
059 public interface SOAPHeader extends SOAPElement {
060
061 /**
062 * Creates a new <CODE>SOAPHeaderElement</CODE> object
063 * initialized with the specified name and adds it to this
064 * <CODE>SOAPHeader</CODE> object.
065 * @param name a <CODE>Name</CODE> object with
066 * the name of the new <CODE>SOAPHeaderElement</CODE>
067 * object
068 * @return the new <CODE>SOAPHeaderElement</CODE> object that
069 * was inserted into this <CODE>SOAPHeader</CODE>
070 * object
071 * @throws SOAPException if a SOAP error occurs
072 */
073 public abstract SOAPHeaderElement addHeaderElement(Name name)
074 throws SOAPException;
075
076 /**
077 * Returns a list of all the <CODE>SOAPHeaderElement</CODE>
078 * objects in this <CODE>SOAPHeader</CODE> object that have the
079 * the specified actor. An actor is a global attribute that
080 * indicates the intermediate parties to whom the message should
081 * be sent. An actor receives the message and then sends it to
082 * the next actor. The default actor is the ultimate intended
083 * recipient for the message, so if no actor attribute is
084 * included in a <CODE>SOAPHeader</CODE> object, the message is
085 * sent to its ultimate destination.
086 * @param actor a <CODE>String</CODE> giving the
087 * URI of the actor for which to search
088 * @return an <CODE>Iterator</CODE> object over all the <CODE>
089 * SOAPHeaderElement</CODE> objects that contain the
090 * specified actor
091 * @see #extractHeaderElements(java.lang.String) extractHeaderElements(java.lang.String)
092 */
093 public abstract Iterator examineHeaderElements(String actor);
094
095 /**
096 * Returns a list of all the <CODE>SOAPHeaderElement</CODE>
097 * objects in this <CODE>SOAPHeader</CODE> object that have
098 * the the specified actor and detaches them from this <CODE>
099 * SOAPHeader</CODE> object.
100 *
101 * <P>This method allows an actor to process only the parts of
102 * the <CODE>SOAPHeader</CODE> object that apply to it and to
103 * remove them before passing the message on to the next
104 * actor.
105 * @param actor a <CODE>String</CODE> giving the
106 * URI of the actor for which to search
107 * @return an <CODE>Iterator</CODE> object over all the <CODE>
108 * SOAPHeaderElement</CODE> objects that contain the
109 * specified actor
110 * @see #examineHeaderElements(java.lang.String) examineHeaderElements(java.lang.String)
111 */
112 public abstract Iterator extractHeaderElements(String actor);
113
114 /**
115 * Returns an <code>Iterator</code> over all the
116 * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader</code>
117 * object that have the specified actor and that have a MustUnderstand
118 * attribute whose value is equivalent to <code>true</code>.
119 *
120 * @param actor a <code>String</code> giving the URI of the actor for which
121 * to search
122 * @return an <code>Iterator</code> object over all the
123 * <code>SOAPHeaderElement</code> objects that contain the
124 * specified actor and are marked as MustUnderstand
125 */
126 public abstract Iterator examineMustUnderstandHeaderElements(String actor);
127
128 /**
129 * Returns an <code>Iterator</code> over all the
130 * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader</code>
131 * object.
132 *
133 * @return an <code>Iterator</code> object over all the
134 * <code>SOAPHeaderElement</code> objects contained by this
135 * <code>SOAPHeader</code>
136 */
137 public abstract Iterator examineAllHeaderElements();
138
139 /**
140 * Returns an <code>Iterator</code> over all the
141 * <code>SOAPHeaderElement</code> objects in this <code>SOAPHeader </code>
142 * object and detaches them from this <code>SOAPHeader</code> object.
143 *
144 * @return an <code>Iterator</code> object over all the
145 * <code>SOAPHeaderElement</code> objects contained by this
146 * <code>SOAPHeader</code>
147 */
148 public abstract Iterator extractAllHeaderElements();
149 }