author | aefimov |
Thu, 23 Nov 2017 18:23:15 +0000 | |
changeset 47930 | f2de2c55c6c7 |
parent 47216 | 71c04702a3d5 |
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:
28326
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 |
||
28 |
||
29 |
import java.io.IOException; |
|
30 |
import java.io.InputStream; |
|
31 |
||
32 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
33 |
* A factory for creating {@code SOAPMessage} objects. |
12009 | 34 |
* <P> |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
35 |
* A SAAJ client can create a {@code MessageFactory} object |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
36 |
* using the method {@code newInstance}, as shown in the following |
12009 | 37 |
* lines of code. |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
38 |
* <pre>{@code |
12009 | 39 |
* MessageFactory mf = MessageFactory.newInstance(); |
40 |
* MessageFactory mf12 = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
41 |
* }</pre> |
12009 | 42 |
* <P> |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
43 |
* All {@code MessageFactory} objects, regardless of how they are |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
44 |
* created, will produce {@code SOAPMessage} objects that |
12009 | 45 |
* have the following elements by default: |
46 |
* <UL> |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
47 |
* <LI>A {@code SOAPPart} object |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
48 |
* <LI>A {@code SOAPEnvelope} object |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
49 |
* <LI>A {@code SOAPBody} object |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
50 |
* <LI>A {@code SOAPHeader} object |
12009 | 51 |
* </UL> |
52 |
* In some cases, specialized MessageFactory objects may be obtained that produce messages |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
53 |
* prepopulated with additional entries in the {@code SOAPHeader} object and the |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
54 |
* {@code SOAPBody} object. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
55 |
* The content of a new {@code SOAPMessage} object depends on which of the two |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
56 |
* {@code MessageFactory} methods is used to create it. |
12009 | 57 |
* <UL> |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
58 |
* <LI>{@code createMessage()} <BR> |
12009 | 59 |
* This is the method clients would normally use to create a request message. |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
60 |
* <LI>{@code createMessage(MimeHeaders, java.io.InputStream)} -- message has |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
61 |
* content from the {@code InputStream} object and headers from the |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
62 |
* {@code MimeHeaders} object <BR> |
12009 | 63 |
* This method can be used internally by a service implementation to |
64 |
* create a message that is a response to a request. |
|
65 |
* </UL> |
|
25840 | 66 |
* |
67 |
* @since 1.6 |
|
12009 | 68 |
*/ |
69 |
public abstract class MessageFactory { |
|
70 |
||
34467
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
31746
diff
changeset
|
71 |
private static final String DEFAULT_MESSAGE_FACTORY |
12009 | 72 |
= "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"; |
73 |
||
74 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
75 |
* Creates a new {@code MessageFactory} object that is an instance |
34467
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
31746
diff
changeset
|
76 |
* of the default implementation (SOAP 1.1). |
12009 | 77 |
* |
34467
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
31746
diff
changeset
|
78 |
* This method uses the lookup procedure specified in {@link javax.xml.soap} to locate and load the |
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
31746
diff
changeset
|
79 |
* {@link javax.xml.soap.MessageFactory} class. |
12009 | 80 |
* |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
81 |
* @return a new instance of a {@code MessageFactory} |
12009 | 82 |
* |
83 |
* @exception SOAPException if there was an error in creating the |
|
84 |
* default implementation of the |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
85 |
* {@code MessageFactory}. |
12009 | 86 |
* @see SAAJMetaFactory |
87 |
*/ |
|
88 |
||
18372
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
89 |
public static MessageFactory newInstance() throws SOAPException { |
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
90 |
|
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
91 |
|
12009 | 92 |
try { |
18372
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
93 |
MessageFactory factory = (MessageFactory) FactoryFinder.find( |
34467
024f1ce7da02
8131334: SAAJ Plugability Layer: using java.util.ServiceLoader
mkos
parents:
31746
diff
changeset
|
94 |
MessageFactory.class, |
18372
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
95 |
DEFAULT_MESSAGE_FACTORY, |
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
96 |
false); |
12009 | 97 |
|
18372
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
98 |
if (factory != null) { |
12009 | 99 |
return factory; |
18372
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
100 |
} |
12009 | 101 |
return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); |
18372
4d90cbb0d70a
8013021: Rebase 8005432 & 8003542 against the latest jdk8/jaxws
mkos
parents:
16791
diff
changeset
|
102 |
|
12009 | 103 |
} catch (Exception ex) { |
104 |
throw new SOAPException( |
|
105 |
"Unable to create message factory for SOAP: " |
|
106 |
+ex.getMessage()); |
|
107 |
} |
|
108 |
||
109 |
} |
|
110 |
||
111 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
112 |
* Creates a new {@code MessageFactory} object that is an instance |
12009 | 113 |
* of the specified implementation. May be a dynamic message factory, |
114 |
* a SOAP 1.1 message factory, or a SOAP 1.2 message factory. A dynamic |
|
115 |
* message factory creates messages based on the MIME headers specified |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
116 |
* as arguments to the {@code createMessage} method. |
12009 | 117 |
* |
118 |
* This method uses the SAAJMetaFactory to locate the implementation class |
|
119 |
* and create the MessageFactory instance. |
|
120 |
* |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
121 |
* @return a new instance of a {@code MessageFactory} |
12009 | 122 |
* |
123 |
* @param protocol a string constant representing the class of the |
|
124 |
* specified message factory implementation. May be |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
125 |
* either {@code DYNAMIC_SOAP_PROTOCOL}, |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
126 |
* {@code DEFAULT_SOAP_PROTOCOL} (which is the same |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
127 |
* as) {@code SOAP_1_1_PROTOCOL}, or |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
128 |
* {@code SOAP_1_2_PROTOCOL}. |
12009 | 129 |
* |
130 |
* @exception SOAPException if there was an error in creating the |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
131 |
* specified implementation of {@code MessageFactory}. |
12009 | 132 |
* @see SAAJMetaFactory |
25840 | 133 |
* @since 1.6, SAAJ 1.3 |
12009 | 134 |
*/ |
135 |
public static MessageFactory newInstance(String protocol) throws SOAPException { |
|
136 |
return SAAJMetaFactory.getInstance().newMessageFactory(protocol); |
|
137 |
} |
|
138 |
||
139 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
140 |
* Creates a new {@code SOAPMessage} object with the default |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
141 |
* {@code SOAPPart}, {@code SOAPEnvelope}, {@code SOAPBody}, |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
142 |
* and {@code SOAPHeader} objects. Profile-specific message factories |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
143 |
* can choose to prepopulate the {@code SOAPMessage} object with |
12009 | 144 |
* profile-specific headers. |
145 |
* <P> |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
146 |
* Content can be added to this message's {@code SOAPPart} object, and |
12009 | 147 |
* the message can be sent "as is" when a message containing only a SOAP part |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
148 |
* is sufficient. Otherwise, the {@code SOAPMessage} object needs |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
149 |
* to create one or more {@code AttachmentPart} objects and |
12009 | 150 |
* add them to itself. Any content that is not in XML format must be |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
151 |
* in an {@code AttachmentPart} object. |
12009 | 152 |
* |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
153 |
* @return a new {@code SOAPMessage} object |
12009 | 154 |
* @exception SOAPException if a SOAP error occurs |
155 |
* @exception UnsupportedOperationException if the protocol of this |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
156 |
* {@code MessageFactory} instance is {@code DYNAMIC_SOAP_PROTOCOL} |
12009 | 157 |
*/ |
158 |
public abstract SOAPMessage createMessage() |
|
159 |
throws SOAPException; |
|
160 |
||
161 |
/** |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
162 |
* Internalizes the contents of the given {@code InputStream} object into a |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
163 |
* new {@code SOAPMessage} object and returns the {@code SOAPMessage} |
12009 | 164 |
* object. |
165 |
* |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
166 |
* @param in the {@code InputStream} object that contains the data |
12009 | 167 |
* for a message |
168 |
* @param headers the transport-specific headers passed to the |
|
169 |
* message in a transport-independent fashion for creation of the |
|
170 |
* message |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
171 |
* @return a new {@code SOAPMessage} object containing the data from |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
172 |
* the given {@code InputStream} object |
12009 | 173 |
* |
174 |
* @exception IOException if there is a problem in reading data from |
|
175 |
* the input stream |
|
176 |
* |
|
177 |
* @exception SOAPException may be thrown if the message is invalid |
|
178 |
* |
|
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
179 |
* @exception IllegalArgumentException if the {@code MessageFactory} |
12009 | 180 |
* requires one or more MIME headers to be present in the |
31746
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
181 |
* {@code headers} parameter and they are missing. |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
182 |
* {@code MessageFactory} implementations for |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
183 |
* {@code SOAP_1_1_PROTOCOL} or |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
184 |
* {@code SOAP_1_2_PROTOCOL} must not throw |
7573de6b8e46
8130753: Sync-up javadoc changes in jax-ws area - includes JAX-B API, JAX-WS API, SAAJ-API
mkos
parents:
28326
diff
changeset
|
185 |
* {@code IllegalArgumentException} for this reason. |
12009 | 186 |
*/ |
187 |
public abstract SOAPMessage createMessage(MimeHeaders headers, |
|
188 |
InputStream in) |
|
189 |
throws IOException, SOAPException; |
|
190 |
} |