1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/javax/xml/soap/SOAPEnvelope.java Tue Mar 06 16:09:35 2012 -0800 1.3 @@ -0,0 +1,200 @@ 1.4 +/* 1.5 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package javax.xml.soap; 1.30 + 1.31 + 1.32 +/** 1.33 + * The container for the SOAPHeader and SOAPBody portions of a 1.34 + * <code>SOAPPart</code> object. By default, a <code>SOAPMessage</code> 1.35 + * object is created with a <code>SOAPPart</code> object that has a 1.36 + * <code>SOAPEnvelope</code> object. The <code>SOAPEnvelope</code> object 1.37 + * by default has an empty <code>SOAPBody</code> object and an empty 1.38 + * <code>SOAPHeader</code> object. The <code>SOAPBody</code> object is 1.39 + * required, and the <code>SOAPHeader</code> object, though 1.40 + * optional, is used in the majority of cases. If the 1.41 + * <code>SOAPHeader</code> object is not needed, it can be deleted, 1.42 + * which is shown later. 1.43 + * <P> 1.44 + * A client can access the <code>SOAPHeader</code> and <code>SOAPBody</code> 1.45 + * objects by calling the methods <code>SOAPEnvelope.getHeader</code> and 1.46 + * <code>SOAPEnvelope.getBody</code>. The 1.47 + * following lines of code use these two methods after starting with 1.48 + * the <code>SOAPMessage</code> 1.49 + * object <i>message</i> to get the <code>SOAPPart</code> object <i>sp</i>, 1.50 + * which is then used to get the <code>SOAPEnvelope</code> object <i>se</i>. 1.51 + * 1.52 + * <PRE> 1.53 + * SOAPPart sp = message.getSOAPPart(); 1.54 + * SOAPEnvelope se = sp.getEnvelope(); 1.55 + * SOAPHeader sh = se.getHeader(); 1.56 + * SOAPBody sb = se.getBody(); 1.57 + * </PRE> 1.58 + * <P> 1.59 + * It is possible to change the body or header of a <code>SOAPEnvelope</code> 1.60 + * object by retrieving the current one, deleting it, and then adding 1.61 + * a new body or header. The <code>javax.xml.soap.Node</code> method 1.62 + * <code>deleteNode</code> deletes the XML element (node) on which it is 1.63 + * called. For example, the following line of code deletes the 1.64 + * <code>SOAPBody</code> object that is retrieved by the method <code>getBody</code>. 1.65 + * <PRE> 1.66 + * se.getBody().detachNode(); 1.67 + * </PRE> 1.68 + * To create a <code>SOAPHeader</code> object to replace the one that was removed, 1.69 + * a client uses 1.70 + * the method <code>SOAPEnvelope.addHeader</code>, which creates a new header and 1.71 + * adds it to the <code>SOAPEnvelope</code> object. Similarly, the method 1.72 + * <code>addBody</code> creates a new <code>SOAPBody</code> object and adds 1.73 + * it to the <code>SOAPEnvelope</code> object. The following code fragment 1.74 + * retrieves the current header, removes it, and adds a new one. Then 1.75 + * it retrieves the current body, removes it, and adds a new one. 1.76 + * 1.77 + * <PRE> 1.78 + * SOAPPart sp = message.getSOAPPart(); 1.79 + * SOAPEnvelope se = sp.getEnvelope(); 1.80 + * se.getHeader().detachNode(); 1.81 + * SOAPHeader sh = se.addHeader(); 1.82 + * se.getBody().detachNode(); 1.83 + * SOAPBody sb = se.addBody(); 1.84 + * </PRE> 1.85 + * It is an error to add a <code>SOAPBody</code> or <code>SOAPHeader</code> 1.86 + * object if one already exists. 1.87 + * <P> 1.88 + * The <code>SOAPEnvelope</code> interface provides three methods for creating 1.89 + * <code>Name</code> objects. One method creates <code>Name</code> objects with 1.90 + * a local name, a namespace prefix, and a namesapce URI. The second method creates 1.91 + * <code>Name</code> objects with a local name and a namespace prefix, and the third 1.92 + * creates <code>Name</code> objects with just a local name. The following line of 1.93 + * code, in which <i>se</i> is a <code>SOAPEnvelope</code> object, creates a new 1.94 + * <code>Name</code> object with all three. 1.95 + * <PRE> 1.96 + * Name name = se.createName("GetLastTradePrice", "WOMBAT", 1.97 + * "http://www.wombat.org/trader"); 1.98 + * </PRE> 1.99 + */ 1.100 +public interface SOAPEnvelope extends SOAPElement { 1.101 + 1.102 + /** 1.103 + * Creates a new <code>Name</code> object initialized with the 1.104 + * given local name, namespace prefix, and namespace URI. 1.105 + * <P> 1.106 + * This factory method creates <code>Name</code> objects for use in 1.107 + * the SOAP/XML document. 1.108 + * 1.109 + * @param localName a <code>String</code> giving the local name 1.110 + * @param prefix a <code>String</code> giving the prefix of the namespace 1.111 + * @param uri a <code>String</code> giving the URI of the namespace 1.112 + * @return a <code>Name</code> object initialized with the given 1.113 + * local name, namespace prefix, and namespace URI 1.114 + * @throws SOAPException if there is a SOAP error 1.115 + */ 1.116 + public abstract Name createName(String localName, String prefix, 1.117 + String uri) 1.118 + throws SOAPException; 1.119 + 1.120 + /** 1.121 + * Creates a new <code>Name</code> object initialized with the 1.122 + * given local name. 1.123 + * <P> 1.124 + * This factory method creates <code>Name</code> objects for use in 1.125 + * the SOAP/XML document. 1.126 + * 1.127 + * @param localName a <code>String</code> giving the local name 1.128 + * @return a <code>Name</code> object initialized with the given 1.129 + * local name 1.130 + * @throws SOAPException if there is a SOAP error 1.131 + */ 1.132 + public abstract Name createName(String localName) 1.133 + throws SOAPException; 1.134 + 1.135 + /** 1.136 + * Returns the <code>SOAPHeader</code> object for 1.137 + * this <code>SOAPEnvelope</code> object. 1.138 + * <P> 1.139 + * A new <code>SOAPMessage</code> object is by default created with a 1.140 + * <code>SOAPEnvelope</code> object that contains an empty 1.141 + * <code>SOAPHeader</code> object. As a result, the method 1.142 + * <code>getHeader</code> will always return a <code>SOAPHeader</code> 1.143 + * object unless the header has been removed and a new one has not 1.144 + * been added. 1.145 + * 1.146 + * @return the <code>SOAPHeader</code> object or <code>null</code> if 1.147 + * there is none 1.148 + * @exception SOAPException if there is a problem obtaining the 1.149 + * <code>SOAPHeader</code> object 1.150 + */ 1.151 + public SOAPHeader getHeader() throws SOAPException; 1.152 + 1.153 + /** 1.154 + * Returns the <code>SOAPBody</code> object associated with this 1.155 + * <code>SOAPEnvelope</code> object. 1.156 + * <P> 1.157 + * A new <code>SOAPMessage</code> object is by default created with a 1.158 + * <code>SOAPEnvelope</code> object that contains an empty 1.159 + * <code>SOAPBody</code> object. As a result, the method 1.160 + * <code>getBody</code> will always return a <code>SOAPBody</code> 1.161 + * object unless the body has been removed and a new one has not 1.162 + * been added. 1.163 + * 1.164 + * @return the <code>SOAPBody</code> object for this 1.165 + * <code>SOAPEnvelope</code> object or <code>null</code> 1.166 + * if there is none 1.167 + * @exception SOAPException if there is a problem obtaining the 1.168 + * <code>SOAPBody</code> object 1.169 + */ 1.170 + public SOAPBody getBody() throws SOAPException; 1.171 + /** 1.172 + * Creates a <code>SOAPHeader</code> object and sets it as the 1.173 + * <code>SOAPHeader</code> object for this <code>SOAPEnvelope</code> 1.174 + * object. 1.175 + * <P> 1.176 + * It is illegal to add a header when the envelope already 1.177 + * contains a header. Therefore, this method should be called 1.178 + * only after the existing header has been removed. 1.179 + * 1.180 + * @return the new <code>SOAPHeader</code> object 1.181 + * 1.182 + * @exception SOAPException if this 1.183 + * <code>SOAPEnvelope</code> object already contains a 1.184 + * valid <code>SOAPHeader</code> object 1.185 + */ 1.186 + public SOAPHeader addHeader() throws SOAPException; 1.187 + /** 1.188 + * Creates a <code>SOAPBody</code> object and sets it as the 1.189 + * <code>SOAPBody</code> object for this <code>SOAPEnvelope</code> 1.190 + * object. 1.191 + * <P> 1.192 + * It is illegal to add a body when the envelope already 1.193 + * contains a body. Therefore, this method should be called 1.194 + * only after the existing body has been removed. 1.195 + * 1.196 + * @return the new <code>SOAPBody</code> object 1.197 + * 1.198 + * @exception SOAPException if this 1.199 + * <code>SOAPEnvelope</code> object already contains a 1.200 + * valid <code>SOAPBody</code> object 1.201 + */ 1.202 + public SOAPBody addBody() throws SOAPException; 1.203 +}