author | lana |
Thu, 11 Aug 2016 15:47:07 +0000 | |
changeset 40243 | 225732b21228 |
parent 31746 | 7573de6b8e46 |
child 45678 | 65fdff10664d |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
2 |
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package javax.xml.soap; |
|
27 |
import java.io.OutputStream; |
|
28 |
import java.io.IOException; |
|
29 |
||
30 |
import java.util.Iterator; |
|
31 |
||
32 |
import javax.activation.DataHandler; |
|
33 |
||
34 |
/** |
|
35 |
* The root class for all SOAP messages. As transmitted on the "wire", a SOAP |
|
36 |
* message is an XML document or a MIME message whose first body part is an |
|
37 |
* XML/SOAP document. |
|
38 |
* <P> |
|
30005 | 39 |
* A {@code SOAPMessage} object consists of a SOAP part and optionally |
40 |
* one or more attachment parts. The SOAP part for a {@code SOAPMessage} |
|
41 |
* object is a {@code SOAPPart} object, which contains information used |
|
12009 | 42 |
* for message routing and identification, and which can contain |
43 |
* application-specific content. All data in the SOAP Part of a message must be |
|
44 |
* in XML format. |
|
45 |
* <P> |
|
30005 | 46 |
* A new {@code SOAPMessage} object contains the following by default: |
12009 | 47 |
* <UL> |
30005 | 48 |
* <LI>A {@code SOAPPart} object |
49 |
* <LI>A {@code SOAPEnvelope} object |
|
50 |
* <LI>A {@code SOAPBody} object |
|
51 |
* <LI>A {@code SOAPHeader} object |
|
12009 | 52 |
* </UL> |
30005 | 53 |
* The SOAP part of a message can be retrieved by calling the method {@code SOAPMessage.getSOAPPart()}. |
54 |
* The {@code SOAPEnvelope} object is retrieved from the {@code SOAPPart} |
|
55 |
* object, and the {@code SOAPEnvelope} object is used to retrieve the |
|
56 |
* {@code SOAPBody} and {@code SOAPHeader} objects. |
|
12009 | 57 |
* |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
58 |
* <pre>{@code |
12009 | 59 |
* SOAPPart sp = message.getSOAPPart(); |
60 |
* SOAPEnvelope se = sp.getEnvelope(); |
|
61 |
* SOAPBody sb = se.getBody(); |
|
62 |
* SOAPHeader sh = se.getHeader(); |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
63 |
* }</pre> |
12009 | 64 |
* |
65 |
* <P> |
|
30005 | 66 |
* In addition to the mandatory {@code SOAPPart} object, a {@code SOAPMessage} |
67 |
* object may contain zero or more {@code AttachmentPart} objects, each |
|
68 |
* of which contains application-specific data. The {@code SOAPMessage} |
|
69 |
* interface provides methods for creating {@code AttachmentPart} |
|
70 |
* objects and also for adding them to a {@code SOAPMessage} object. A |
|
71 |
* party that has received a {@code SOAPMessage} object can examine its |
|
12009 | 72 |
* contents by retrieving individual attachment parts. |
73 |
* <P> |
|
74 |
* Unlike the rest of a SOAP message, an attachment is not required to be in |
|
75 |
* XML format and can therefore be anything from simple text to an image file. |
|
76 |
* Consequently, any message content that is not in XML format must be in an |
|
30005 | 77 |
* {@code AttachmentPart} object. |
12009 | 78 |
* <P> |
30005 | 79 |
* A {@code MessageFactory} object may create {@code SOAPMessage} |
12009 | 80 |
* objects with behavior that is specialized to a particular implementation or |
30005 | 81 |
* application of SAAJ. For instance, a {@code MessageFactory} object |
82 |
* may produce {@code SOAPMessage} objects that conform to a particular |
|
83 |
* Profile such as ebXML. In this case a {@code MessageFactory} object |
|
84 |
* might produce {@code SOAPMessage} objects that are initialized with |
|
12009 | 85 |
* ebXML headers. |
86 |
* <P> |
|
87 |
* In order to ensure backward source compatibility, methods that are added to |
|
88 |
* this class after version 1.1 of the SAAJ specification are all concrete |
|
89 |
* instead of abstract and they all have default implementations. Unless |
|
90 |
* otherwise noted in the JavaDocs for those methods the default |
|
30005 | 91 |
* implementations simply throw an {@code UnsupportedOperationException} |
12009 | 92 |
* and the SAAJ implementation code must override them with methods that |
93 |
* provide the specified behavior. Legacy client code does not have this |
|
94 |
* restriction, however, so long as there is no claim made that it conforms to |
|
95 |
* some later version of the specification than it was originally written for. |
|
96 |
* A legacy class that extends the SOAPMessage class can be compiled and/or run |
|
97 |
* against succeeding versions of the SAAJ API without modification. If such a |
|
98 |
* class was correctly implemented then it will continue to behave correctly |
|
99 |
* relative to the version of the specification against which it was written. |
|
100 |
* |
|
101 |
* @see MessageFactory |
|
102 |
* @see AttachmentPart |
|
25840 | 103 |
* @since 1.6 |
12009 | 104 |
*/ |
105 |
public abstract class SOAPMessage { |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
106 |
|
12009 | 107 |
/** |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
108 |
* Specifies the character type encoding for the SOAP Message. Valid values |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
109 |
* include "utf-8" and "utf-16". See vendor documentation for additional |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
110 |
* supported values. The default is "utf-8". |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
111 |
* |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
112 |
* @see SOAPMessage#setProperty(String, Object) SOAPMessage.setProperty |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
113 |
* @since 1.6, SAAJ 1.2 |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
114 |
*/ |
12009 | 115 |
public static final String CHARACTER_SET_ENCODING = |
116 |
"javax.xml.soap.character-set-encoding"; |
|
117 |
||
118 |
/** |
|
119 |
* Specifies whether the SOAP Message will contain an XML declaration when |
|
120 |
* it is sent. The only valid values are "true" and "false". The default is |
|
121 |
* "false". |
|
122 |
* |
|
123 |
* @see SOAPMessage#setProperty(String, Object) SOAPMessage.setProperty |
|
25840 | 124 |
* @since 1.6, SAAJ 1.2 |
12009 | 125 |
*/ |
126 |
public static final String WRITE_XML_DECLARATION = |
|
127 |
"javax.xml.soap.write-xml-declaration"; |
|
128 |
||
129 |
/** |
|
30005 | 130 |
* Sets the description of this {@code SOAPMessage} object's |
12009 | 131 |
* content with the given description. |
132 |
* |
|
30005 | 133 |
* @param description a {@code String} describing the content of this |
12009 | 134 |
* message |
135 |
* @see #getContentDescription |
|
136 |
*/ |
|
137 |
public abstract void setContentDescription(String description); |
|
138 |
||
139 |
/** |
|
30005 | 140 |
* Retrieves a description of this {@code SOAPMessage} object's |
12009 | 141 |
* content. |
142 |
* |
|
30005 | 143 |
* @return a {@code String} describing the content of this |
144 |
* message or {@code null} if no description has been set |
|
12009 | 145 |
* @see #setContentDescription |
146 |
*/ |
|
147 |
public abstract String getContentDescription(); |
|
148 |
||
149 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
150 |
* Gets the SOAP part of this {@code SOAPMessage} object. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
151 |
* <p> |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
152 |
* {@code SOAPMessage} object contains one or more attachments, the |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
153 |
* SOAP Part must be the first MIME body part in the message. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
154 |
* |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
155 |
* @return the {@code SOAPPart} object for this {@code SOAPMessage} |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
156 |
* object |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
157 |
*/ |
12009 | 158 |
public abstract SOAPPart getSOAPPart(); |
159 |
||
160 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
161 |
* Gets the SOAP Body contained in this {@code SOAPMessage} object. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
162 |
* |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
163 |
* @return the {@code SOAPBody} object contained by this {@code SOAPMessage} |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
164 |
* object |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
165 |
* @throws SOAPException if the SOAP Body does not exist or cannot be retrieved |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
166 |
* @since 1.6, SAAJ 1.2 |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
167 |
*/ |
12009 | 168 |
public SOAPBody getSOAPBody() throws SOAPException { |
169 |
throw new UnsupportedOperationException("getSOAPBody must be overridden by all subclasses of SOAPMessage"); |
|
170 |
} |
|
171 |
||
172 |
/** |
|
30005 | 173 |
* Gets the SOAP Header contained in this {@code SOAPMessage} object. |
174 |
* |
|
175 |
* @return the {@code SOAPHeader} object contained |
|
176 |
* by this {@code SOAPMessage} object |
|
177 |
* @exception SOAPException |
|
178 |
* if the SOAP Header does not exist or cannot be retrieved |
|
179 |
* @since 1.6, SAAJ 1.2 |
|
180 |
*/ |
|
12009 | 181 |
public SOAPHeader getSOAPHeader() throws SOAPException { |
182 |
throw new UnsupportedOperationException("getSOAPHeader must be overridden by all subclasses of SOAPMessage"); |
|
183 |
} |
|
184 |
||
185 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
186 |
* Removes all {@code AttachmentPart} objects that have been added |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
187 |
* to this {@code SOAPMessage} object. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
188 |
* <p> |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
189 |
* This method does not touch the SOAP part. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
190 |
*/ |
12009 | 191 |
public abstract void removeAllAttachments(); |
192 |
||
193 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
194 |
* Gets a count of the number of attachments in this message. This count |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
195 |
* does not include the SOAP part. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
196 |
* |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
197 |
* @return the number of {@code AttachmentPart} objects that are |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
198 |
* part of this {@code SOAPMessage} object |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
199 |
*/ |
12009 | 200 |
public abstract int countAttachments(); |
201 |
||
202 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
203 |
* Retrieves all the {@code AttachmentPart} objects that are part of |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
204 |
* this {@code SOAPMessage} object. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
205 |
* |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
206 |
* @return an iterator over all the attachments in this message |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
207 |
*/ |
12009 | 208 |
public abstract Iterator getAttachments(); |
209 |
||
210 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
211 |
* Retrieves all the {@code AttachmentPart} objects that have header |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
212 |
* entries that match the specified headers. Note that a returned |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
213 |
* attachment could have headers in addition to those specified. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
214 |
* |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
215 |
* @param headers a {@code MimeHeaders} object containing the MIME |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
216 |
* headers for which to search |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
217 |
* @return an iterator over all attachments that have a header that matches |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
218 |
* one of the given headers |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
30005
diff
changeset
|
219 |
*/ |
12009 | 220 |
public abstract Iterator getAttachments(MimeHeaders headers); |
221 |
||
222 |
/** |
|
30005 | 223 |
* Removes all the {@code AttachmentPart} objects that have header |
12009 | 224 |
* entries that match the specified headers. Note that the removed |
225 |
* attachment could have headers in addition to those specified. |
|
226 |
* |
|
227 |
* @param headers |
|
30005 | 228 |
* a {@code MimeHeaders} object containing the MIME |
12009 | 229 |
* headers for which to search |
25840 | 230 |
* @since 1.6, SAAJ 1.3 |
12009 | 231 |
*/ |
232 |
public abstract void removeAttachments(MimeHeaders headers); |
|
233 |
||
234 |
||
235 |
/** |
|
30005 | 236 |
* Returns an {@code AttachmentPart} object that is associated with an |
237 |
* attachment that is referenced by this {@code SOAPElement} or |
|
238 |
* {@code null} if no such attachment exists. References can be made |
|
239 |
* via an {@code href} attribute as described in |
|
240 |
* <a href="http://www.w3.org/TR/SOAP-attachments#SOAPReferenceToAttachements">SOAP Messages with Attachments</a>, |
|
241 |
* or via a single {@code Text} child node containing a URI as |
|
12009 | 242 |
* described in the WS-I Attachments Profile 1.0 for elements of schema |
30005 | 243 |
* type <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html">ref:swaRef</a>. |
244 |
* These two mechanisms must be supported. |
|
245 |
* The support for references via {@code href} attribute also implies that |
|
12009 | 246 |
* this method should also be supported on an element that is an |
247 |
* <i>xop:Include</i> element ( |
|
30005 | 248 |
* <a href="http://www.w3.org/2000/xp/Group/3/06/Attachments/XOP.html">XOP</a>). |
12009 | 249 |
* other reference mechanisms may be supported by individual |
250 |
* implementations of this standard. Contact your vendor for details. |
|
251 |
* |
|
30005 | 252 |
* @param element The {@code SOAPElement} containing the reference to an Attachment |
253 |
* @return the referenced {@code AttachmentPart} or null if no such |
|
254 |
* {@code AttachmentPart} exists or no reference can be |
|
255 |
* found in this {@code SOAPElement}. |
|
12009 | 256 |
* @throws SOAPException if there is an error in the attempt to access the |
257 |
* attachment |
|
258 |
* |
|
25840 | 259 |
* @since 1.6, SAAJ 1.3 |
12009 | 260 |
*/ |
261 |
public abstract AttachmentPart getAttachment(SOAPElement element) throws SOAPException; |
|
262 |
||
263 |
||
264 |
/** |
|
30005 | 265 |
* Adds the given {@code AttachmentPart} object to this {@code SOAPMessage} |
266 |
* object. An {@code AttachmentPart} object must be created before |
|
12009 | 267 |
* it can be added to a message. |
268 |
* |
|
269 |
* @param AttachmentPart |
|
30005 | 270 |
* an {@code AttachmentPart} object that is to become part |
271 |
* of this {@code SOAPMessage} object |
|
12009 | 272 |
* @exception IllegalArgumentException |
273 |
*/ |
|
274 |
public abstract void addAttachmentPart(AttachmentPart AttachmentPart); |
|
275 |
||
276 |
/** |
|
30005 | 277 |
* Creates a new empty {@code AttachmentPart} object. Note that the |
278 |
* method {@code addAttachmentPart} must be called with this new |
|
279 |
* {@code AttachmentPart} object as the parameter in order for it to |
|
280 |
* become an attachment to this {@code SOAPMessage} object. |
|
12009 | 281 |
* |
30005 | 282 |
* @return a new {@code AttachmentPart} object that can be populated |
283 |
* and added to this {@code SOAPMessage} object |
|
12009 | 284 |
*/ |
285 |
public abstract AttachmentPart createAttachmentPart(); |
|
286 |
||
287 |
/** |
|
30005 | 288 |
* Creates an {@code AttachmentPart} object and populates it using |
289 |
* the given {@code DataHandler} object. |
|
12009 | 290 |
* |
291 |
* @param dataHandler |
|
30005 | 292 |
* the {@code javax.activation.DataHandler} object that |
293 |
* will generate the content for this {@code SOAPMessage} |
|
12009 | 294 |
* object |
30005 | 295 |
* @return a new {@code AttachmentPart} object that contains data |
296 |
* generated by the given {@code DataHandler} object |
|
12009 | 297 |
* @exception IllegalArgumentException |
30005 | 298 |
* if there was a problem with the specified {@code DataHandler} |
12009 | 299 |
* object |
300 |
* @see javax.activation.DataHandler |
|
301 |
* @see javax.activation.DataContentHandler |
|
302 |
*/ |
|
303 |
public AttachmentPart createAttachmentPart(DataHandler dataHandler) { |
|
304 |
AttachmentPart attachment = createAttachmentPart(); |
|
305 |
attachment.setDataHandler(dataHandler); |
|
306 |
return attachment; |
|
307 |
} |
|
308 |
||
309 |
/** |
|
30005 | 310 |
* Returns all the transport-specific MIME headers for this {@code SOAPMessage} |
12009 | 311 |
* object in a transport-independent fashion. |
312 |
* |
|
30005 | 313 |
* @return a {@code MimeHeaders} object containing the {@code MimeHeader} |
12009 | 314 |
* objects |
315 |
*/ |
|
316 |
public abstract MimeHeaders getMimeHeaders(); |
|
317 |
||
318 |
/** |
|
30005 | 319 |
* Creates an {@code AttachmentPart} object and populates it with |
12009 | 320 |
* the specified data of the specified content type. The type of the |
30005 | 321 |
* {@code Object} should correspond to the value given for the |
322 |
* {@code Content-Type}. |
|
12009 | 323 |
* |
324 |
* @param content |
|
30005 | 325 |
* an {@code Object} containing the content for the |
326 |
* {@code AttachmentPart} object to be created |
|
12009 | 327 |
* @param contentType |
30005 | 328 |
* a {@code String} object giving the type of content; |
12009 | 329 |
* examples are "text/xml", "text/plain", and "image/jpeg" |
30005 | 330 |
* @return a new {@code AttachmentPart} object that contains the |
12009 | 331 |
* given data |
332 |
* @exception IllegalArgumentException |
|
333 |
* may be thrown if the contentType does not match the type |
|
334 |
* of the content object, or if there was no |
|
30005 | 335 |
* {@code DataContentHandler} object for the given |
12009 | 336 |
* content object |
337 |
* @see javax.activation.DataHandler |
|
338 |
* @see javax.activation.DataContentHandler |
|
339 |
*/ |
|
340 |
public AttachmentPart createAttachmentPart( |
|
341 |
Object content, |
|
342 |
String contentType) { |
|
343 |
AttachmentPart attachment = createAttachmentPart(); |
|
344 |
attachment.setContent(content, contentType); |
|
345 |
return attachment; |
|
346 |
} |
|
347 |
||
348 |
/** |
|
30005 | 349 |
* Updates this {@code SOAPMessage} object with all the changes that |
12009 | 350 |
* have been made to it. This method is called automatically when |
351 |
* {@link SOAPMessage#writeTo(OutputStream)} is called. However, if |
|
352 |
* changes are made to a message that was received or to one that has |
|
30005 | 353 |
* already been sent, the method {@code saveChanges} needs to be |
354 |
* called explicitly in order to save the changes. The method {@code saveChanges} |
|
12009 | 355 |
* also generates any changes that can be read back (for example, a |
356 |
* MessageId in profiles that support a message id). All MIME headers in a |
|
357 |
* message that is created for sending purposes are guaranteed to have |
|
30005 | 358 |
* valid values only after {@code saveChanges} has been called. |
12009 | 359 |
* <P> |
360 |
* In addition, this method marks the point at which the data from all |
|
30005 | 361 |
* constituent {@code AttachmentPart} objects are pulled into the |
12009 | 362 |
* message. |
363 |
* |
|
30005 | 364 |
* @exception SOAPException if there was a problem saving |
365 |
* changes to this message. |
|
12009 | 366 |
*/ |
367 |
public abstract void saveChanges() throws SOAPException; |
|
368 |
||
369 |
/** |
|
30005 | 370 |
* Indicates whether this {@code SOAPMessage} object needs to have |
371 |
* the method {@code saveChanges} called on it. |
|
12009 | 372 |
* |
30005 | 373 |
* @return {@code true} if {@code saveChanges} needs to be |
374 |
* called; {@code false} otherwise. |
|
12009 | 375 |
*/ |
376 |
public abstract boolean saveRequired(); |
|
377 |
||
378 |
/** |
|
30005 | 379 |
* Writes this {@code SOAPMessage} object to the given output |
12009 | 380 |
* stream. The externalization format is as defined by the SOAP 1.1 with |
381 |
* Attachments specification. |
|
382 |
* <P> |
|
383 |
* If there are no attachments, just an XML stream is written out. For |
|
30005 | 384 |
* those messages that have attachments, {@code writeTo} writes a |
12009 | 385 |
* MIME-encoded byte stream. |
386 |
* <P> |
|
387 |
* Note that this method does not write the transport-specific MIME Headers |
|
388 |
* of the Message |
|
389 |
* |
|
390 |
* @param out |
|
30005 | 391 |
* the {@code OutputStream} object to which this {@code SOAPMessage} |
12009 | 392 |
* object will be written |
393 |
* @exception IOException |
|
394 |
* if an I/O error occurs |
|
395 |
* @exception SOAPException |
|
396 |
* if there was a problem in externalizing this SOAP message |
|
397 |
*/ |
|
398 |
public abstract void writeTo(OutputStream out) |
|
399 |
throws SOAPException, IOException; |
|
400 |
||
401 |
/** |
|
402 |
* Associates the specified value with the specified property. If there was |
|
403 |
* already a value associated with this property, the old value is |
|
404 |
* replaced. |
|
405 |
* <p> |
|
406 |
* The valid property names include |
|
407 |
* {@link SOAPMessage#WRITE_XML_DECLARATION} and |
|
408 |
* {@link SOAPMessage#CHARACTER_SET_ENCODING}. All of these standard SAAJ |
|
409 |
* properties are prefixed by "javax.xml.soap". Vendors may also add |
|
410 |
* implementation specific properties. These properties must be prefixed |
|
411 |
* with package names that are unique to the vendor. |
|
412 |
* <p> |
|
30005 | 413 |
* Setting the property {@code WRITE_XML_DECLARATION} to {@code "true"} |
12009 | 414 |
* will cause an XML Declaration to be written out at the start of the SOAP |
415 |
* message. The default value of "false" suppresses this declaration. |
|
416 |
* <p> |
|
30005 | 417 |
* The property {@code CHARACTER_SET_ENCODING} defaults to the value |
418 |
* {@code "utf-8"} which causes the SOAP message to be encoded using |
|
419 |
* UTF-8. Setting {@code CHARACTER_SET_ENCODING} to {@code "utf-16"} |
|
12009 | 420 |
* causes the SOAP message to be encoded using UTF-16. |
421 |
* <p> |
|
422 |
* Some implementations may allow encodings in addition to UTF-8 and |
|
423 |
* UTF-16. Refer to your vendor's documentation for details. |
|
424 |
* |
|
425 |
* @param property |
|
426 |
* the property with which the specified value is to be |
|
427 |
* associated. |
|
428 |
* @param value |
|
429 |
* the value to be associated with the specified property |
|
430 |
* @exception SOAPException |
|
431 |
* if the property name is not recognized. |
|
25840 | 432 |
* @since 1.6, SAAJ 1.2 |
12009 | 433 |
*/ |
434 |
public void setProperty(String property, Object value) |
|
435 |
throws SOAPException { |
|
436 |
throw new UnsupportedOperationException("setProperty must be overridden by all subclasses of SOAPMessage"); |
|
437 |
} |
|
438 |
||
439 |
/** |
|
440 |
* Retrieves value of the specified property. |
|
441 |
* |
|
442 |
* @param property |
|
443 |
* the name of the property to retrieve |
|
30005 | 444 |
* @return the value associated with the named property or {@code null} |
12009 | 445 |
* if no such property exists. |
446 |
* @exception SOAPException |
|
447 |
* if the property name is not recognized. |
|
25840 | 448 |
* @since 1.6, SAAJ 1.2 |
12009 | 449 |
*/ |
450 |
public Object getProperty(String property) throws SOAPException { |
|
451 |
throw new UnsupportedOperationException("getProperty must be overridden by all subclasses of SOAPMessage"); |
|
452 |
} |
|
453 |
} |