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