Fri, 04 Oct 2013 16:21:34 +0100
8025054: Update JAX-WS RI integration to 2.2.9-b130926.1035
Reviewed-by: chegar
ohair@286 | 1 | /* |
alanb@368 | 2 | * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package javax.xml.soap; |
ohair@286 | 27 | |
ohair@286 | 28 | import java.util.Iterator; |
ohair@286 | 29 | |
ohair@286 | 30 | import javax.xml.transform.Source; |
ohair@286 | 31 | |
ohair@286 | 32 | /** |
ohair@286 | 33 | * The container for the SOAP-specific portion of a <code>SOAPMessage</code> |
ohair@286 | 34 | * object. All messages are required to have a SOAP part, so when a |
ohair@286 | 35 | * <code>SOAPMessage</code> object is created, it will automatically |
ohair@286 | 36 | * have a <code>SOAPPart</code> object. |
ohair@286 | 37 | *<P> |
ohair@286 | 38 | * A <code>SOAPPart</code> object is a MIME part and has the MIME headers |
ohair@286 | 39 | * Content-Id, Content-Location, and Content-Type. Because the value of |
ohair@286 | 40 | * Content-Type must be "text/xml", a <code>SOAPPart</code> object automatically |
ohair@286 | 41 | * has a MIME header of Content-Type with its value set to "text/xml". |
ohair@286 | 42 | * The value must be "text/xml" because content in the SOAP part of a |
ohair@286 | 43 | * message must be in XML format. Content that is not of type "text/xml" |
ohair@286 | 44 | * must be in an <code>AttachmentPart</code> object rather than in the |
ohair@286 | 45 | * <code>SOAPPart</code> object. |
ohair@286 | 46 | * <P> |
ohair@286 | 47 | * When a message is sent, its SOAP part must have the MIME header Content-Type |
ohair@286 | 48 | * set to "text/xml". Or, from the other perspective, the SOAP part of any |
ohair@286 | 49 | * message that is received must have the MIME header Content-Type with a |
ohair@286 | 50 | * value of "text/xml". |
ohair@286 | 51 | * <P> |
ohair@286 | 52 | * A client can access the <code>SOAPPart</code> object of a |
ohair@286 | 53 | * <code>SOAPMessage</code> object by |
ohair@286 | 54 | * calling the method <code>SOAPMessage.getSOAPPart</code>. The |
ohair@286 | 55 | * following line of code, in which <code>message</code> is a |
ohair@286 | 56 | * <code>SOAPMessage</code> object, retrieves the SOAP part of a message. |
ohair@286 | 57 | * <PRE> |
ohair@286 | 58 | * SOAPPart soapPart = message.getSOAPPart(); |
ohair@286 | 59 | * </PRE> |
ohair@286 | 60 | * <P> |
ohair@286 | 61 | * A <code>SOAPPart</code> object contains a <code>SOAPEnvelope</code> object, |
ohair@286 | 62 | * which in turn contains a <code>SOAPBody</code> object and a |
ohair@286 | 63 | * <code>SOAPHeader</code> object. |
ohair@286 | 64 | * The <code>SOAPPart</code> method <code>getEnvelope</code> can be used |
ohair@286 | 65 | * to retrieve the <code>SOAPEnvelope</code> object. |
ohair@286 | 66 | * <P> |
ohair@286 | 67 | */ |
ohair@286 | 68 | public abstract class SOAPPart implements org.w3c.dom.Document, Node { |
ohair@286 | 69 | |
ohair@286 | 70 | /** |
ohair@286 | 71 | * Gets the <code>SOAPEnvelope</code> object associated with this |
ohair@286 | 72 | * <code>SOAPPart</code> object. Once the SOAP envelope is obtained, it |
ohair@286 | 73 | * can be used to get its contents. |
ohair@286 | 74 | * |
ohair@286 | 75 | * @return the <code>SOAPEnvelope</code> object for this |
ohair@286 | 76 | * <code>SOAPPart</code> object |
ohair@286 | 77 | * @exception SOAPException if there is a SOAP error |
ohair@286 | 78 | */ |
ohair@286 | 79 | public abstract SOAPEnvelope getEnvelope() throws SOAPException; |
ohair@286 | 80 | |
ohair@286 | 81 | /** |
ohair@286 | 82 | * Retrieves the value of the MIME header whose name is "Content-Id". |
ohair@286 | 83 | * |
ohair@286 | 84 | * @return a <code>String</code> giving the value of the MIME header |
ohair@286 | 85 | * named "Content-Id" |
ohair@286 | 86 | * @see #setContentId |
ohair@286 | 87 | */ |
ohair@286 | 88 | public String getContentId() { |
ohair@286 | 89 | String[] values = getMimeHeader("Content-Id"); |
ohair@286 | 90 | if (values != null && values.length > 0) |
ohair@286 | 91 | return values[0]; |
ohair@286 | 92 | return null; |
ohair@286 | 93 | } |
ohair@286 | 94 | |
ohair@286 | 95 | /** |
ohair@286 | 96 | * Retrieves the value of the MIME header whose name is "Content-Location". |
ohair@286 | 97 | * |
ohair@286 | 98 | * @return a <code>String</code> giving the value of the MIME header whose |
ohair@286 | 99 | * name is "Content-Location" |
ohair@286 | 100 | * @see #setContentLocation |
ohair@286 | 101 | */ |
ohair@286 | 102 | public String getContentLocation() { |
ohair@286 | 103 | String[] values = getMimeHeader("Content-Location"); |
ohair@286 | 104 | if (values != null && values.length > 0) |
ohair@286 | 105 | return values[0]; |
ohair@286 | 106 | return null; |
ohair@286 | 107 | } |
ohair@286 | 108 | |
ohair@286 | 109 | /** |
ohair@286 | 110 | * Sets the value of the MIME header named "Content-Id" |
ohair@286 | 111 | * to the given <code>String</code>. |
ohair@286 | 112 | * |
ohair@286 | 113 | * @param contentId a <code>String</code> giving the value of the MIME |
ohair@286 | 114 | * header "Content-Id" |
ohair@286 | 115 | * |
ohair@286 | 116 | * @exception IllegalArgumentException if there is a problem in |
ohair@286 | 117 | * setting the content id |
ohair@286 | 118 | * @see #getContentId |
ohair@286 | 119 | */ |
ohair@286 | 120 | public void setContentId(String contentId) |
ohair@286 | 121 | { |
ohair@286 | 122 | setMimeHeader("Content-Id", contentId); |
ohair@286 | 123 | } |
ohair@286 | 124 | /** |
ohair@286 | 125 | * Sets the value of the MIME header "Content-Location" |
ohair@286 | 126 | * to the given <code>String</code>. |
ohair@286 | 127 | * |
ohair@286 | 128 | * @param contentLocation a <code>String</code> giving the value |
ohair@286 | 129 | * of the MIME |
ohair@286 | 130 | * header "Content-Location" |
ohair@286 | 131 | * @exception IllegalArgumentException if there is a problem in |
ohair@286 | 132 | * setting the content location. |
ohair@286 | 133 | * @see #getContentLocation |
ohair@286 | 134 | */ |
ohair@286 | 135 | public void setContentLocation(String contentLocation) |
ohair@286 | 136 | { |
ohair@286 | 137 | setMimeHeader("Content-Location", contentLocation); |
ohair@286 | 138 | } |
ohair@286 | 139 | /** |
ohair@286 | 140 | * Removes all MIME headers that match the given name. |
ohair@286 | 141 | * |
ohair@286 | 142 | * @param header a <code>String</code> giving the name of the MIME header(s) to |
ohair@286 | 143 | * be removed |
ohair@286 | 144 | */ |
ohair@286 | 145 | public abstract void removeMimeHeader(String header); |
ohair@286 | 146 | |
ohair@286 | 147 | /** |
ohair@286 | 148 | * Removes all the <code>MimeHeader</code> objects for this |
ohair@286 | 149 | * <code>SOAPEnvelope</code> object. |
ohair@286 | 150 | */ |
ohair@286 | 151 | public abstract void removeAllMimeHeaders(); |
ohair@286 | 152 | |
ohair@286 | 153 | /** |
ohair@286 | 154 | * Gets all the values of the <code>MimeHeader</code> object |
ohair@286 | 155 | * in this <code>SOAPPart</code> object that |
ohair@286 | 156 | * is identified by the given <code>String</code>. |
ohair@286 | 157 | * |
ohair@286 | 158 | * @param name the name of the header; example: "Content-Type" |
ohair@286 | 159 | * @return a <code>String</code> array giving all the values for the |
ohair@286 | 160 | * specified header |
ohair@286 | 161 | * @see #setMimeHeader |
ohair@286 | 162 | */ |
ohair@286 | 163 | public abstract String[] getMimeHeader(String name); |
ohair@286 | 164 | |
ohair@286 | 165 | /** |
ohair@286 | 166 | * Changes the first header entry that matches the given header name |
ohair@286 | 167 | * so that its value is the given value, adding a new header with the |
ohair@286 | 168 | * given name and value if no |
ohair@286 | 169 | * existing header is a match. If there is a match, this method clears |
ohair@286 | 170 | * all existing values for the first header that matches and sets the |
ohair@286 | 171 | * given value instead. If more than one header has |
ohair@286 | 172 | * the given name, this method removes all of the matching headers after |
ohair@286 | 173 | * the first one. |
ohair@286 | 174 | * <P> |
ohair@286 | 175 | * Note that RFC822 headers can contain only US-ASCII characters. |
ohair@286 | 176 | * |
ohair@286 | 177 | * @param name a <code>String</code> giving the header name |
ohair@286 | 178 | * for which to search |
ohair@286 | 179 | * @param value a <code>String</code> giving the value to be set. |
ohair@286 | 180 | * This value will be substituted for the current value(s) |
ohair@286 | 181 | * of the first header that is a match if there is one. |
ohair@286 | 182 | * If there is no match, this value will be the value for |
ohair@286 | 183 | * a new <code>MimeHeader</code> object. |
ohair@286 | 184 | * |
ohair@286 | 185 | * @exception IllegalArgumentException if there was a problem with |
ohair@286 | 186 | * the specified mime header name or value |
ohair@286 | 187 | * @see #getMimeHeader |
ohair@286 | 188 | */ |
ohair@286 | 189 | public abstract void setMimeHeader(String name, String value); |
ohair@286 | 190 | |
ohair@286 | 191 | /** |
ohair@286 | 192 | * Creates a <code>MimeHeader</code> object with the specified |
ohair@286 | 193 | * name and value and adds it to this <code>SOAPPart</code> object. |
ohair@286 | 194 | * If a <code>MimeHeader</code> with the specified name already |
ohair@286 | 195 | * exists, this method adds the specified value to the already |
ohair@286 | 196 | * existing value(s). |
ohair@286 | 197 | * <P> |
ohair@286 | 198 | * Note that RFC822 headers can contain only US-ASCII characters. |
ohair@286 | 199 | * |
ohair@286 | 200 | * @param name a <code>String</code> giving the header name |
ohair@286 | 201 | * @param value a <code>String</code> giving the value to be set |
ohair@286 | 202 | * or added |
ohair@286 | 203 | * @exception IllegalArgumentException if there was a problem with |
ohair@286 | 204 | * the specified mime header name or value |
ohair@286 | 205 | */ |
ohair@286 | 206 | public abstract void addMimeHeader(String name, String value); |
ohair@286 | 207 | |
ohair@286 | 208 | /** |
ohair@286 | 209 | * Retrieves all the headers for this <code>SOAPPart</code> object |
ohair@286 | 210 | * as an iterator over the <code>MimeHeader</code> objects. |
ohair@286 | 211 | * |
ohair@286 | 212 | * @return an <code>Iterator</code> object with all of the Mime |
ohair@286 | 213 | * headers for this <code>SOAPPart</code> object |
ohair@286 | 214 | */ |
ohair@286 | 215 | public abstract Iterator getAllMimeHeaders(); |
ohair@286 | 216 | |
ohair@286 | 217 | /** |
ohair@286 | 218 | * Retrieves all <code>MimeHeader</code> objects that match a name in |
ohair@286 | 219 | * the given array. |
ohair@286 | 220 | * |
ohair@286 | 221 | * @param names a <code>String</code> array with the name(s) of the |
ohair@286 | 222 | * MIME headers to be returned |
ohair@286 | 223 | * @return all of the MIME headers that match one of the names in the |
ohair@286 | 224 | * given array, returned as an <code>Iterator</code> object |
ohair@286 | 225 | */ |
ohair@286 | 226 | public abstract Iterator getMatchingMimeHeaders(String[] names); |
ohair@286 | 227 | |
ohair@286 | 228 | /** |
ohair@286 | 229 | * Retrieves all <code>MimeHeader</code> objects whose name does |
ohair@286 | 230 | * not match a name in the given array. |
ohair@286 | 231 | * |
ohair@286 | 232 | * @param names a <code>String</code> array with the name(s) of the |
ohair@286 | 233 | * MIME headers not to be returned |
ohair@286 | 234 | * @return all of the MIME headers in this <code>SOAPPart</code> object |
ohair@286 | 235 | * except those that match one of the names in the |
ohair@286 | 236 | * given array. The nonmatching MIME headers are returned as an |
ohair@286 | 237 | * <code>Iterator</code> object. |
ohair@286 | 238 | */ |
ohair@286 | 239 | public abstract Iterator getNonMatchingMimeHeaders(String[] names); |
ohair@286 | 240 | |
ohair@286 | 241 | /** |
ohair@286 | 242 | * Sets the content of the <code>SOAPEnvelope</code> object with the data |
ohair@286 | 243 | * from the given <code>Source</code> object. This <code>Source</code> |
ohair@286 | 244 | * must contain a valid SOAP document. |
ohair@286 | 245 | * |
ohair@286 | 246 | * @param source the <code>javax.xml.transform.Source</code> object with the |
ohair@286 | 247 | * data to be set |
ohair@286 | 248 | * |
ohair@286 | 249 | * @exception SOAPException if there is a problem in setting the source |
ohair@286 | 250 | * @see #getContent |
ohair@286 | 251 | */ |
ohair@286 | 252 | public abstract void setContent(Source source) throws SOAPException; |
ohair@286 | 253 | |
ohair@286 | 254 | /** |
ohair@286 | 255 | * Returns the content of the SOAPEnvelope as a JAXP <code>Source</code> |
ohair@286 | 256 | * object. |
ohair@286 | 257 | * |
ohair@286 | 258 | * @return the content as a <code>javax.xml.transform.Source</code> object |
ohair@286 | 259 | * |
ohair@286 | 260 | * @exception SOAPException if the implementation cannot convert |
ohair@286 | 261 | * the specified <code>Source</code> object |
ohair@286 | 262 | * @see #setContent |
ohair@286 | 263 | */ |
ohair@286 | 264 | public abstract Source getContent() throws SOAPException; |
ohair@286 | 265 | } |