12009
|
1 |
/*
|
|
2 |
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
|
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 com.sun.xml.internal.ws.api.message;
|
|
27 |
|
|
28 |
import com.sun.istack.internal.NotNull;
|
|
29 |
import com.sun.istack.internal.Nullable;
|
|
30 |
import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
|
|
31 |
import com.sun.xml.internal.ws.addressing.WsaPropertyBag;
|
|
32 |
import com.sun.xml.internal.ws.addressing.WsaTubeHelper;
|
|
33 |
import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException;
|
|
34 |
import com.sun.xml.internal.ws.api.*;
|
|
35 |
import com.sun.xml.internal.ws.api.addressing.AddressingVersion;
|
|
36 |
import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
|
|
37 |
import com.sun.xml.internal.ws.api.message.saaj.SAAJFactory;
|
|
38 |
import com.sun.xml.internal.ws.api.model.JavaMethod;
|
|
39 |
import com.sun.xml.internal.ws.api.model.SEIModel;
|
|
40 |
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation;
|
|
41 |
import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
|
|
42 |
import com.sun.xml.internal.ws.api.pipe.Codec;
|
|
43 |
import com.sun.xml.internal.ws.api.pipe.Tube;
|
|
44 |
import com.sun.xml.internal.ws.api.server.Adapter;
|
|
45 |
import com.sun.xml.internal.ws.api.server.TransportBackChannel;
|
|
46 |
import com.sun.xml.internal.ws.api.server.WSEndpoint;
|
|
47 |
import com.sun.xml.internal.ws.api.server.WebServiceContextDelegate;
|
|
48 |
import com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory;
|
|
49 |
import com.sun.xml.internal.ws.client.*;
|
|
50 |
import com.sun.xml.internal.ws.developer.JAXWSProperties;
|
|
51 |
import com.sun.xml.internal.ws.message.RelatesToHeader;
|
|
52 |
import com.sun.xml.internal.ws.message.StringHeader;
|
|
53 |
import com.sun.xml.internal.ws.transport.http.WSHTTPConnection;
|
|
54 |
import com.sun.xml.internal.ws.message.saaj.SAAJMessage;
|
|
55 |
import com.sun.xml.internal.ws.server.WSEndpointImpl;
|
|
56 |
import com.sun.xml.internal.ws.util.DOMUtil;
|
|
57 |
import com.sun.xml.internal.ws.util.xml.XmlUtil;
|
|
58 |
import com.sun.xml.internal.ws.wsdl.DispatchException;
|
|
59 |
import com.sun.xml.internal.ws.wsdl.OperationDispatcher;
|
|
60 |
|
|
61 |
import com.sun.xml.internal.org.jvnet.ws.message.ContentType;
|
|
62 |
import org.w3c.dom.Document;
|
|
63 |
import org.w3c.dom.Element;
|
|
64 |
import org.xml.sax.SAXException;
|
|
65 |
|
|
66 |
import javax.xml.namespace.QName;
|
|
67 |
import javax.xml.soap.SOAPException;
|
|
68 |
import javax.xml.soap.SOAPMessage;
|
|
69 |
import javax.xml.stream.XMLStreamWriter;
|
|
70 |
import javax.xml.ws.BindingProvider;
|
|
71 |
import javax.xml.ws.Dispatch;
|
|
72 |
import javax.xml.ws.WebServiceContext;
|
|
73 |
import javax.xml.ws.WebServiceException;
|
|
74 |
import javax.xml.ws.handler.LogicalMessageContext;
|
|
75 |
import javax.xml.ws.handler.MessageContext;
|
|
76 |
import javax.xml.ws.handler.soap.SOAPMessageContext;
|
|
77 |
import java.util.*;
|
|
78 |
import java.util.logging.Logger;
|
|
79 |
import java.io.ByteArrayOutputStream;
|
|
80 |
import java.io.IOException;
|
|
81 |
import java.io.OutputStream;
|
|
82 |
import java.nio.ByteBuffer;
|
|
83 |
import java.nio.channels.WritableByteChannel;
|
|
84 |
|
|
85 |
/**
|
|
86 |
* Represents a container of a {@link Message}.
|
|
87 |
*
|
|
88 |
* <h2>What is a {@link Packet}?</h2>
|
|
89 |
* <p>
|
|
90 |
* A packet can be thought of as a frame/envelope/package that wraps
|
|
91 |
* a {@link Message}. A packet keeps track of optional metadata (properties)
|
|
92 |
* about a {@link Message} that doesn't go across the wire.
|
|
93 |
* This roughly corresponds to {@link MessageContext} in the JAX-WS API.
|
|
94 |
*
|
|
95 |
* <p>
|
|
96 |
* Usually a packet contains a {@link Message} in it, but sometimes
|
|
97 |
* (such as for a reply of an one-way operation), a packet may
|
|
98 |
* float around without a {@link Message} in it.
|
|
99 |
*
|
|
100 |
*
|
|
101 |
* <a name="properties"></a>
|
|
102 |
* <h2>Properties</h2>
|
|
103 |
* <p>
|
|
104 |
* Information frequently used inside the JAX-WS RI
|
|
105 |
* is stored in the strongly-typed fields. Other information is stored
|
|
106 |
* in terms of a generic {@link Map} (see
|
|
107 |
* {@link #invocationProperties}.)
|
|
108 |
*
|
|
109 |
* <p>
|
|
110 |
* Some properties need to be retained between request and response,
|
|
111 |
* some don't. For strongly typed fields, this characteristic is
|
|
112 |
* statically known for each of them, and propagation happens accordingly.
|
|
113 |
* For generic information stored in {@link Map}, {@link #invocationProperties}
|
|
114 |
* stores per-invocation scope information (which carries over to
|
|
115 |
* the response.)
|
|
116 |
*
|
|
117 |
* <p>
|
|
118 |
* This object is used as the backing store of {@link MessageContext}, and
|
|
119 |
* {@link LogicalMessageContext} and {@link SOAPMessageContext} will
|
|
120 |
* be delegating to this object for storing/retrieving values.
|
|
121 |
*
|
|
122 |
*
|
|
123 |
* <h3>Relationship to request/response context</h3>
|
|
124 |
* <p>
|
|
125 |
* {@link BindingProvider#getRequestContext() Request context} is used to
|
|
126 |
* seed the initial values of {@link Packet}.
|
|
127 |
* Some of those values go to strongly-typed fields, and others go to
|
|
128 |
* {@link #invocationProperties}, as they need to be retained in the reply message.
|
|
129 |
*
|
|
130 |
* <p>
|
|
131 |
* Similarly, {@link BindingProvider#getResponseContext() response context}
|
|
132 |
* is constructed from {@link Packet} (or rather it's just a view of {@link Packet}.)
|
|
133 |
* by using properties from {@link #invocationProperties},
|
|
134 |
* modulo properties named explicitly in {@link #getHandlerScopePropertyNames(boolean)}.
|
|
135 |
* IOW, properties added to {@link #invocationProperties}
|
|
136 |
* are exposed to the response context by default.
|
|
137 |
*
|
|
138 |
*
|
|
139 |
*
|
|
140 |
* <h3>TODO</h3>
|
|
141 |
* <ol>
|
|
142 |
* <li>this class needs to be cloneable since Message is copiable.
|
|
143 |
* <li>The three live views aren't implemented correctly. It will be
|
|
144 |
* more work to do so, although I'm sure it's possible.
|
|
145 |
* <li>{@link Property} annotation is to make it easy
|
|
146 |
* for {@link MessageContext} to export properties on this object,
|
|
147 |
* but it probably needs some clean up.
|
|
148 |
* </ol>
|
|
149 |
*
|
|
150 |
* @author Kohsuke Kawaguchi
|
|
151 |
*/
|
|
152 |
public final class Packet
|
|
153 |
extends DistributedPropertySet
|
|
154 |
implements com.sun.xml.internal.org.jvnet.ws.message.MessageContext
|
|
155 |
{
|
|
156 |
|
|
157 |
/**
|
|
158 |
* Creates a {@link Packet} that wraps a given {@link Message}.
|
|
159 |
*
|
|
160 |
* <p>
|
|
161 |
* This method should be only used to create a fresh {@link Packet}.
|
|
162 |
* To create a {@link Packet} for a reply, use {@link #createResponse(Message)}.
|
|
163 |
*
|
|
164 |
* @param request
|
|
165 |
* The request {@link Message}. Can be null.
|
|
166 |
*/
|
|
167 |
public Packet(Message request) {
|
|
168 |
this();
|
|
169 |
this.message = request;
|
|
170 |
}
|
|
171 |
|
|
172 |
/**
|
|
173 |
* Creates an empty {@link Packet} that doesn't have any {@link Message}.
|
|
174 |
*/
|
|
175 |
public Packet() {
|
|
176 |
this.invocationProperties = new HashMap<String, Object>();
|
|
177 |
}
|
|
178 |
|
|
179 |
/**
|
|
180 |
* Used by {@link #createResponse(Message)} and {@link #copy(boolean)}.
|
|
181 |
*/
|
|
182 |
private Packet(Packet that) {
|
|
183 |
that.copySatelliteInto((DistributedPropertySet) this);
|
|
184 |
this.handlerConfig = that.handlerConfig;
|
|
185 |
this.invocationProperties = that.invocationProperties;
|
|
186 |
this.handlerScopePropertyNames = that.handlerScopePropertyNames;
|
|
187 |
this.contentNegotiation = that.contentNegotiation;
|
|
188 |
this.wasTransportSecure = that.wasTransportSecure;
|
|
189 |
this.transportBackChannel = that.transportBackChannel;
|
|
190 |
this.endpointAddress = that.endpointAddress;
|
|
191 |
this.isAdapterDeliversNonAnonymousResponse = that.isAdapterDeliversNonAnonymousResponse;
|
|
192 |
this.wsdlOperation = that.wsdlOperation;
|
|
193 |
this.acceptableMimeTypes = that.acceptableMimeTypes;
|
|
194 |
this.endpoint = that.endpoint;
|
|
195 |
this.proxy = that.proxy;
|
|
196 |
this.webServiceContextDelegate = that.webServiceContextDelegate;
|
|
197 |
this.soapAction = that.soapAction;
|
|
198 |
this.expectReply = that.expectReply;
|
|
199 |
this.component = that.component;
|
|
200 |
// copy other properties that need to be copied. is there any?
|
|
201 |
}
|
|
202 |
|
|
203 |
/**
|
|
204 |
* Creates a copy of this {@link Packet}.
|
|
205 |
*
|
|
206 |
* @param copyMessage determines whether the {@link Message} from the original {@link Packet} should be copied as
|
|
207 |
* well, or not. If the value is {@code false}, the {@link Message} in the copy of the {@link Packet} is {@code null}.
|
|
208 |
* @return copy of the original packet
|
|
209 |
*/
|
|
210 |
public Packet copy(boolean copyMessage) {
|
|
211 |
// the copy constructor is originally designed for creating a response packet,
|
|
212 |
// but so far the implementation is usable for this purpose as well, so calling the copy constructor
|
|
213 |
// to avoid code dupliation.
|
|
214 |
Packet copy = new Packet(this);
|
|
215 |
if (copyMessage && this.message != null) {
|
|
216 |
copy.message = this.message.copy();
|
|
217 |
}
|
|
218 |
|
|
219 |
return copy;
|
|
220 |
}
|
|
221 |
|
|
222 |
private Message message;
|
|
223 |
|
|
224 |
/**
|
|
225 |
* Gets the last {@link Message} set through {@link #setMessage(Message)}.
|
|
226 |
*
|
|
227 |
* @return may null. See the class javadoc for when it's null.
|
|
228 |
*/
|
|
229 |
public Message getMessage() {
|
|
230 |
return message;
|
|
231 |
}
|
|
232 |
|
|
233 |
public WSBinding getBinding() {
|
|
234 |
if (endpoint != null)
|
|
235 |
return endpoint.getBinding();
|
|
236 |
if (proxy != null)
|
|
237 |
return (WSBinding) proxy.getBinding();
|
|
238 |
return null;
|
|
239 |
}
|
|
240 |
/**
|
|
241 |
* Sets a {@link Message} to this packet.
|
|
242 |
*
|
|
243 |
* @param message Can be null.
|
|
244 |
*/
|
|
245 |
public void setMessage(Message message) {
|
|
246 |
this.message = message;
|
|
247 |
}
|
|
248 |
|
|
249 |
private QName wsdlOperation;
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Returns the QName of the wsdl operation associated with this packet.
|
|
253 |
* <p/>
|
|
254 |
* Information such as Payload QName, wsa:Action header, SOAPAction HTTP header are used depending on the features
|
|
255 |
* enabled on the particular port.
|
|
256 |
*
|
|
257 |
* @return null if there is no WSDL model or
|
|
258 |
* runtime cannot uniquely identify the wsdl operation from the information in the packet.
|
|
259 |
*/
|
|
260 |
@com.sun.xml.internal.ws.api.PropertySet.Property(MessageContext.WSDL_OPERATION)
|
|
261 |
public final
|
|
262 |
@Nullable
|
|
263 |
QName getWSDLOperation() {
|
|
264 |
if (wsdlOperation != null)
|
|
265 |
return wsdlOperation;
|
|
266 |
|
|
267 |
OperationDispatcher opDispatcher = null;
|
|
268 |
if (endpoint != null) {
|
|
269 |
opDispatcher = ((WSEndpointImpl) endpoint).getOperationDispatcher();
|
|
270 |
} else if (proxy != null) {
|
|
271 |
opDispatcher = ((Stub) proxy).getOperationDispatcher();
|
|
272 |
}
|
|
273 |
//OpDispatcher is null when there is no WSDLModel
|
|
274 |
if (opDispatcher != null) {
|
|
275 |
try {
|
|
276 |
wsdlOperation = opDispatcher.getWSDLOperationQName(this);
|
|
277 |
} catch (DispatchException e) {
|
|
278 |
//Ignore, this might be a protocol message which may not have a wsdl operation
|
|
279 |
//LOGGER.info("Cannot resolve wsdl operation that this Packet is targeted for.");
|
|
280 |
}
|
|
281 |
}
|
|
282 |
return wsdlOperation;
|
|
283 |
}
|
|
284 |
|
|
285 |
/**
|
|
286 |
* Set the wsdl operation to avoid lookup from other data.
|
|
287 |
* This is useful in SEI based clients, where the WSDL operation can be known
|
|
288 |
* from the associated {@link JavaMethod}
|
|
289 |
*
|
|
290 |
* @param wsdlOp QName
|
|
291 |
*/
|
|
292 |
public void setWSDLOperation(QName wsdlOp) {
|
|
293 |
this.wsdlOperation = wsdlOp;
|
|
294 |
}
|
|
295 |
|
|
296 |
/**
|
|
297 |
* True if this message came from a transport (IOW inbound),
|
|
298 |
* and in paricular from a "secure" transport. A transport
|
|
299 |
* needs to set this flag appropriately.
|
|
300 |
*
|
|
301 |
* <p>
|
|
302 |
* This is a requirement from the security team.
|
|
303 |
*/
|
|
304 |
// TODO: expose this as a property
|
|
305 |
public boolean wasTransportSecure;
|
|
306 |
|
|
307 |
/**
|
|
308 |
* Inbound transport headers are captured in a transport neutral way.
|
|
309 |
* Transports are expected to fill this data after creating a Packet.
|
|
310 |
* <p>
|
|
311 |
* {@link SOAPMessage#getMimeHeaders()} would return these headers.
|
|
312 |
*/
|
|
313 |
public static final String INBOUND_TRANSPORT_HEADERS = "com.sun.xml.internal.ws.api.message.packet.inbound.transport.headers";
|
|
314 |
|
|
315 |
/**
|
|
316 |
* Outbound transport headers are captured in a transport neutral way.
|
|
317 |
*
|
|
318 |
* <p>
|
|
319 |
* Transports may choose to ignore certain headers that interfere with
|
|
320 |
* its correct operation, such as
|
|
321 |
* <tt>Content-Type</tt> and <tt>Content-Length</tt>.
|
|
322 |
*/
|
|
323 |
public static final String OUTBOUND_TRANSPORT_HEADERS = "com.sun.xml.internal.ws.api.message.packet.outbound.transport.headers";
|
|
324 |
|
|
325 |
/**
|
|
326 |
*
|
|
327 |
*/
|
|
328 |
public static final String HA_INFO = "com.sun.xml.internal.ws.api.message.packet.hainfo";
|
|
329 |
|
|
330 |
|
|
331 |
/**
|
|
332 |
* This property holds the snapshot of HandlerConfiguration
|
|
333 |
* at the time of invocation.
|
|
334 |
* This property is used by MUPipe and HandlerPipe implementations.
|
|
335 |
*/
|
|
336 |
@com.sun.xml.internal.ws.api.PropertySet.Property(BindingProviderProperties.JAXWS_HANDLER_CONFIG)
|
|
337 |
public HandlerConfiguration handlerConfig;
|
|
338 |
|
|
339 |
/**
|
|
340 |
* If a message originates from a proxy stub that implements
|
|
341 |
* a port interface, this field is set to point to that object.
|
|
342 |
*
|
|
343 |
* TODO: who's using this property?
|
|
344 |
*/
|
|
345 |
@com.sun.xml.internal.ws.api.PropertySet.Property(BindingProviderProperties.JAXWS_CLIENT_HANDLE_PROPERTY)
|
|
346 |
public BindingProvider proxy;
|
|
347 |
|
|
348 |
/**
|
|
349 |
* Determines if the governing {@link Adapter} or {@link Fiber.CompletionCallback} will handle delivering
|
|
350 |
* response messages targeted at non-anonymous endpoint addresses. Prior to the introduction of this
|
|
351 |
* flag the {@link WsaServerTube} would deliver non-anonymous responses.
|
|
352 |
*/
|
|
353 |
public boolean isAdapterDeliversNonAnonymousResponse;
|
|
354 |
|
|
355 |
/**
|
|
356 |
* The endpoint address to which this message is sent to.
|
|
357 |
*
|
|
358 |
* <p>
|
|
359 |
* The JAX-WS spec allows this to be changed for each message,
|
|
360 |
* so it's designed to be a property.
|
|
361 |
*
|
|
362 |
* <p>
|
|
363 |
* Must not be null for a request message on the client. Otherwise
|
|
364 |
* it's null.
|
|
365 |
*/
|
|
366 |
public EndpointAddress endpointAddress;
|
|
367 |
|
|
368 |
/**
|
|
369 |
* @deprecated
|
|
370 |
* The programatic acccess should be done via
|
|
371 |
* {@link #endpointAddress}. This is for JAX-WS client applications
|
|
372 |
* that access this property via {@link BindingProvider#ENDPOINT_ADDRESS_PROPERTY}.
|
|
373 |
*/
|
|
374 |
@com.sun.xml.internal.ws.api.PropertySet.Property(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)
|
|
375 |
public String getEndPointAddressString() {
|
|
376 |
if (endpointAddress == null)
|
|
377 |
return null;
|
|
378 |
else
|
|
379 |
return endpointAddress.toString();
|
|
380 |
}
|
|
381 |
|
|
382 |
public void setEndPointAddressString(String s) {
|
|
383 |
if (s == null)
|
|
384 |
this.endpointAddress = null;
|
|
385 |
else
|
|
386 |
this.endpointAddress = EndpointAddress.create(s);
|
|
387 |
}
|
|
388 |
|
|
389 |
/**
|
|
390 |
* The value of {@link ContentNegotiation#PROPERTY}
|
|
391 |
* property.
|
|
392 |
* <p/>
|
|
393 |
* This property is used only on the client side.
|
|
394 |
*/
|
|
395 |
public ContentNegotiation contentNegotiation;
|
|
396 |
|
|
397 |
@com.sun.xml.internal.ws.api.PropertySet.Property(ContentNegotiation.PROPERTY)
|
|
398 |
public String getContentNegotiationString() {
|
|
399 |
return (contentNegotiation != null) ? contentNegotiation.toString() : null;
|
|
400 |
}
|
|
401 |
|
|
402 |
public void setContentNegotiationString(String s) {
|
|
403 |
if (s == null)
|
|
404 |
contentNegotiation = null;
|
|
405 |
else {
|
|
406 |
try {
|
|
407 |
contentNegotiation = ContentNegotiation.valueOf(s);
|
|
408 |
} catch (IllegalArgumentException e) {
|
|
409 |
// If the value is not recognized default to none
|
|
410 |
contentNegotiation = ContentNegotiation.none;
|
|
411 |
}
|
|
412 |
}
|
|
413 |
}
|
|
414 |
|
|
415 |
/**
|
|
416 |
* Gives a list of Reference Parameters in the Message
|
|
417 |
* <p>
|
|
418 |
* Headers which have attribute wsa:IsReferenceParameter="true"
|
|
419 |
* This is not cached as one may reset the Message.
|
|
420 |
*<p>
|
|
421 |
*/
|
|
422 |
@com.sun.xml.internal.ws.api.PropertySet.Property(MessageContext.REFERENCE_PARAMETERS)
|
|
423 |
public
|
|
424 |
@NotNull
|
|
425 |
List<Element> getReferenceParameters() {
|
|
426 |
List<Element> refParams = new ArrayList<Element>();
|
|
427 |
if (message == null) {
|
|
428 |
return refParams;
|
|
429 |
}
|
|
430 |
HeaderList hl = message.getHeaders();
|
|
431 |
for (Header h : hl) {
|
|
432 |
String attr = h.getAttribute(AddressingVersion.W3C.nsUri, "IsReferenceParameter");
|
|
433 |
if (attr != null && (attr.equals("true") || attr.equals("1"))) {
|
|
434 |
Document d = DOMUtil.createDom();
|
|
435 |
SAX2DOMEx s2d = new SAX2DOMEx(d);
|
|
436 |
try {
|
|
437 |
h.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
|
|
438 |
refParams.add((Element) d.getLastChild());
|
|
439 |
} catch (SAXException e) {
|
|
440 |
throw new WebServiceException(e);
|
|
441 |
}
|
|
442 |
/*
|
|
443 |
DOMResult result = new DOMResult(d);
|
|
444 |
XMLDOMWriterImpl domwriter = new XMLDOMWriterImpl(result);
|
|
445 |
try {
|
|
446 |
h.writeTo(domwriter);
|
|
447 |
refParams.add((Element) result.getNode().getLastChild());
|
|
448 |
} catch (XMLStreamException e) {
|
|
449 |
throw new WebServiceException(e);
|
|
450 |
}
|
|
451 |
*/
|
|
452 |
}
|
|
453 |
}
|
|
454 |
return refParams;
|
|
455 |
}
|
|
456 |
|
|
457 |
/**
|
|
458 |
* @deprecated
|
|
459 |
* This method is for exposing header list through {@link PropertySet#get(Object)},
|
|
460 |
* for user applications, and should never be invoked directly from within the JAX-WS RI.
|
|
461 |
*/
|
|
462 |
@com.sun.xml.internal.ws.api.PropertySet.Property(JAXWSProperties.INBOUND_HEADER_LIST_PROPERTY)
|
|
463 |
/*package*/ HeaderList getHeaderList() {
|
|
464 |
if (message == null) return null;
|
|
465 |
return message.getHeaders();
|
|
466 |
}
|
|
467 |
|
|
468 |
/**
|
|
469 |
* The list of MIME types that are acceptable to a receiver
|
|
470 |
* of an outbound message.
|
|
471 |
*
|
|
472 |
* This property is used only on the server side.
|
|
473 |
*
|
|
474 |
* <p>The representation shall be that specified by the HTTP Accept
|
|
475 |
* request-header field.
|
|
476 |
*
|
|
477 |
* <p>The list of content types will be obtained from the transport
|
|
478 |
* meta-data of a inbound message in a request/response message exchange.
|
|
479 |
* Hence this property will be set by the service-side transport pipe.
|
|
480 |
*/
|
|
481 |
public String acceptableMimeTypes;
|
|
482 |
|
|
483 |
/**
|
|
484 |
* When non-null, this object is consulted to
|
|
485 |
* implement {@link WebServiceContext} methods
|
|
486 |
* exposed to the user application.
|
|
487 |
*
|
|
488 |
* Used only on the server side.
|
|
489 |
*
|
|
490 |
* <p>
|
|
491 |
* This property is set from the parameter
|
|
492 |
* of {@link WSEndpoint.PipeHead#process}.
|
|
493 |
*/
|
|
494 |
public WebServiceContextDelegate webServiceContextDelegate;
|
|
495 |
|
|
496 |
/**
|
|
497 |
* Used only on the server side so that the transport
|
|
498 |
* can close the connection early.
|
|
499 |
*
|
|
500 |
* <p>
|
|
501 |
* This field can be null. While a message is being processed,
|
|
502 |
* this field can be set explicitly to null, to prevent
|
|
503 |
* future pipes from closing a transport (see {@link #keepTransportBackChannelOpen()})
|
|
504 |
*
|
|
505 |
* <p>
|
|
506 |
* This property is set from the parameter
|
|
507 |
* of {@link WSEndpoint.PipeHead#process}.
|
|
508 |
*/
|
|
509 |
public
|
|
510 |
@Nullable
|
|
511 |
TransportBackChannel transportBackChannel;
|
|
512 |
|
|
513 |
/**
|
|
514 |
* Keeps the transport back channel open (by seeting {@link #transportBackChannel} to null.)
|
|
515 |
*
|
|
516 |
* @return
|
|
517 |
* The previous value of {@link #transportBackChannel}.
|
|
518 |
*/
|
|
519 |
public TransportBackChannel keepTransportBackChannelOpen() {
|
|
520 |
TransportBackChannel r = transportBackChannel;
|
|
521 |
transportBackChannel = null;
|
|
522 |
return r;
|
|
523 |
}
|
|
524 |
|
|
525 |
/**
|
|
526 |
* The governing owner of this packet. On the service-side this is the {@link Adapter} and on the client it is the {@link Stub}.
|
|
527 |
*
|
|
528 |
*/
|
|
529 |
public Component component;
|
|
530 |
|
|
531 |
/**
|
|
532 |
* The governing {@link WSEndpoint} in which this message is floating.
|
|
533 |
*
|
|
534 |
* <p>
|
|
535 |
* This property is set if and only if this is on the server side.
|
|
536 |
*/
|
|
537 |
@com.sun.xml.internal.ws.api.PropertySet.Property(JAXWSProperties.WSENDPOINT)
|
|
538 |
public WSEndpoint endpoint;
|
|
539 |
|
|
540 |
/**
|
|
541 |
* The value of the SOAPAction header associated with the message.
|
|
542 |
*
|
|
543 |
* <p>
|
|
544 |
* For outgoing messages, the transport may sends out this value.
|
|
545 |
* If this field is null, the transport may choose to send <tt>""</tt>
|
|
546 |
* (quoted empty string.)
|
|
547 |
*
|
|
548 |
* For incoming messages, the transport will set this field.
|
|
549 |
* If the incoming message did not contain the SOAPAction header,
|
|
550 |
* the transport sets this field to null.
|
|
551 |
*
|
|
552 |
* <p>
|
|
553 |
* If the value is non-null, it must be always in the quoted form.
|
|
554 |
* The value can be null.
|
|
555 |
*
|
|
556 |
* <p>
|
|
557 |
* Note that the way the transport sends this value out depends on
|
|
558 |
* transport and SOAP version.
|
|
559 |
* <p/>
|
|
560 |
* For HTTP transport and SOAP 1.1, BP requires that SOAPAction
|
|
561 |
* header is present (See {@BP R2744} and {@BP R2745}.) For SOAP 1.2,
|
|
562 |
* this is moved to the parameter of the "application/soap+xml".
|
|
563 |
*/
|
|
564 |
@com.sun.xml.internal.ws.api.PropertySet.Property(BindingProvider.SOAPACTION_URI_PROPERTY)
|
|
565 |
public String soapAction;
|
|
566 |
|
|
567 |
/**
|
|
568 |
* A hint indicating that whether a transport should expect
|
|
569 |
* a reply back from the server.
|
|
570 |
*
|
|
571 |
* <p>
|
|
572 |
* This property is used on the client-side for
|
|
573 |
* outbound messages, so that a pipeline
|
|
574 |
* can communicate to the terminal (or intermediate) {@link Tube}s
|
|
575 |
* about this knowledge.
|
|
576 |
*
|
|
577 |
* <p>
|
|
578 |
* This property <b>MUST NOT</b> be used by 2-way transports
|
|
579 |
* that have the transport back channel. Those transports
|
|
580 |
* must always check a reply coming through the transport back
|
|
581 |
* channel regardless of this value, and act accordingly.
|
|
582 |
* (This is because the expectation of the client and
|
|
583 |
* that of the server can be different, for example because
|
|
584 |
* of a bug in user's configuration.)
|
|
585 |
*
|
|
586 |
* <p>
|
|
587 |
* This property is for one-way transports, and more
|
|
588 |
* specifically for the coordinator that correlates sent requests
|
|
589 |
* and incoming replies, to decide whether to block
|
|
590 |
* until a response is received.
|
|
591 |
*
|
|
592 |
* <p>
|
|
593 |
* Also note that this property is related to
|
|
594 |
* {@link WSDLOperation#isOneWay()} but not the same thing.
|
|
595 |
* In fact in general, they are completely orthogonal.
|
|
596 |
*
|
|
597 |
* For example, the calling application can choose to invoke
|
|
598 |
* {@link Dispatch#invoke(Object)} or {@link Dispatch#invokeOneWay(Object)}
|
|
599 |
* with an operation (which determines the value of this property),
|
|
600 |
* regardless of whether WSDL actually says it's one way or not.
|
|
601 |
* So these two booleans can take any combinations.
|
|
602 |
*
|
|
603 |
*
|
|
604 |
* <p>
|
|
605 |
* When this property is {@link Boolean#FALSE}, it means that
|
|
606 |
* the pipeline does not expect a reply from a server (and therefore
|
|
607 |
* the correlator should not block for a reply message
|
|
608 |
* -- if such a reply does arrive, it can be just ignored.)
|
|
609 |
*
|
|
610 |
* <p>
|
|
611 |
* When this property is {@link Boolean#TRUE}, it means that
|
|
612 |
* the pipeline expects a reply from a server (and therefore
|
|
613 |
* the correlator should block to see if a reply message is received,
|
|
614 |
*
|
|
615 |
* <p>
|
|
616 |
* This property is always set to {@link Boolean#TRUE} or
|
|
617 |
* {@link Boolean#FALSE} when used on the request message
|
|
618 |
* on the client side.
|
|
619 |
* No other {@link Boolean} instances are allowed.
|
|
620 |
* <p>
|
|
621 |
*
|
|
622 |
* In all other situations, this property is null.
|
|
623 |
*
|
|
624 |
*/
|
|
625 |
@com.sun.xml.internal.ws.api.PropertySet.Property(BindingProviderProperties.ONE_WAY_OPERATION)
|
|
626 |
public Boolean expectReply;
|
|
627 |
|
|
628 |
|
|
629 |
/**
|
|
630 |
* This property will be removed in a near future.
|
|
631 |
*
|
|
632 |
* <p>
|
|
633 |
* A part of what this flag represented moved to
|
|
634 |
* {@link #expectReply} and the other part was moved
|
|
635 |
* to {@link Message#isOneWay(WSDLPort)}. Please update
|
|
636 |
* your code soon, or risk breaking your build!!
|
|
637 |
*/
|
|
638 |
@Deprecated
|
|
639 |
public Boolean isOneWay;
|
|
640 |
|
|
641 |
/**
|
|
642 |
* Indicates whether is invoking a synchronous pattern. If true, no
|
|
643 |
* async client programming model (e.g. AsyncResponse or AsyncHandler)
|
|
644 |
* were used to make the request that created this packet.
|
|
645 |
*/
|
|
646 |
public Boolean isSynchronousMEP;
|
|
647 |
|
|
648 |
/**
|
|
649 |
* Indicates whether a non-null AsyncHandler was given at the point of
|
|
650 |
* making the request that created this packet. This flag can be used
|
|
651 |
* by Tube implementations to decide how to react when isSynchronousMEP
|
|
652 |
* is false. If true, the client gave a non-null AsyncHandler instance
|
|
653 |
* at the point of request, and will be expecting a response on that
|
|
654 |
* handler when this request has been processed.
|
|
655 |
*/
|
|
656 |
public Boolean nonNullAsyncHandlerGiven;
|
|
657 |
|
|
658 |
/**
|
|
659 |
* Lazily created set of handler-scope property names.
|
|
660 |
*
|
|
661 |
* <p>
|
|
662 |
* We expect that this is only used when handlers are present
|
|
663 |
* and they explicitly set some handler-scope values.
|
|
664 |
*
|
|
665 |
* @see #getHandlerScopePropertyNames(boolean)
|
|
666 |
*/
|
|
667 |
private Set<String> handlerScopePropertyNames;
|
|
668 |
|
|
669 |
/**
|
|
670 |
* Bag to capture properties that are available for the whole
|
|
671 |
* message invocation (namely on both requests and responses.)
|
|
672 |
*
|
|
673 |
* <p>
|
|
674 |
* These properties are copied from a request to a response.
|
|
675 |
* This is where we keep properties that are set by handlers.
|
|
676 |
*
|
|
677 |
* <p>
|
|
678 |
* See <a href="#properties">class javadoc</a> for more discussion.
|
|
679 |
*
|
|
680 |
* @see #getHandlerScopePropertyNames(boolean)
|
|
681 |
*/
|
|
682 |
public final Map<String, Object> invocationProperties;
|
|
683 |
|
|
684 |
/**
|
|
685 |
* Gets a {@link Set} that stores handler-scope properties.
|
|
686 |
*
|
|
687 |
* <p>
|
|
688 |
* These properties will not be exposed to the response context.
|
|
689 |
* Consequently, if a {@link Tube} wishes to hide a property
|
|
690 |
* to {@link ResponseContext}, it needs to add the property name
|
|
691 |
* to this set.
|
|
692 |
*
|
|
693 |
* @param readOnly
|
|
694 |
* Return true if the caller only intends to read the value of this set.
|
|
695 |
* Internally, the {@link Set} is allocated lazily, and this flag helps
|
|
696 |
* optimizing the strategy.
|
|
697 |
*
|
|
698 |
* @return
|
|
699 |
* always non-null, possibly empty set that stores property names.
|
|
700 |
*/
|
|
701 |
public final Set<String> getHandlerScopePropertyNames(boolean readOnly) {
|
|
702 |
Set<String> o = this.handlerScopePropertyNames;
|
|
703 |
if (o == null) {
|
|
704 |
if (readOnly)
|
|
705 |
return Collections.emptySet();
|
|
706 |
o = new HashSet<String>();
|
|
707 |
this.handlerScopePropertyNames = o;
|
|
708 |
}
|
|
709 |
return o;
|
|
710 |
}
|
|
711 |
|
|
712 |
/**
|
|
713 |
* This method no longer works.
|
|
714 |
*
|
|
715 |
* @deprecated
|
|
716 |
* Use {@link #getHandlerScopePropertyNames(boolean)}.
|
|
717 |
* To be removed once Tango components are updated.
|
|
718 |
*/
|
|
719 |
public final Set<String> getApplicationScopePropertyNames(boolean readOnly) {
|
|
720 |
assert false;
|
|
721 |
return new HashSet<String>();
|
|
722 |
}
|
|
723 |
|
|
724 |
/**
|
|
725 |
* Creates a response {@link Packet} from a request packet ({@code this}).
|
|
726 |
*
|
|
727 |
* <p>
|
|
728 |
* When a {@link Packet} for a reply is created, some properties need to be
|
|
729 |
* copied over from a request to a response, and this method handles it correctly.
|
|
730 |
*
|
|
731 |
* @deprecated
|
|
732 |
* Use createClientResponse(Message) for client side and
|
|
733 |
* createServerResponse(Message, String) for server side response
|
|
734 |
* creation.
|
|
735 |
*
|
|
736 |
* @param msg
|
|
737 |
* The {@link Message} that represents a reply. Can be null.
|
|
738 |
*/
|
|
739 |
@Deprecated
|
|
740 |
public Packet createResponse(Message msg) {
|
|
741 |
Packet response = new Packet(this);
|
|
742 |
response.setMessage(msg);
|
|
743 |
return response;
|
|
744 |
}
|
|
745 |
|
|
746 |
/**
|
|
747 |
* Creates a response {@link Packet} from a request packet ({@code this}).
|
|
748 |
*
|
|
749 |
* <p>
|
|
750 |
* When a {@link Packet} for a reply is created, some properties need to be
|
|
751 |
* copied over from a request to a response, and this method handles it correctly.
|
|
752 |
*
|
|
753 |
* @param msg
|
|
754 |
* The {@link Message} that represents a reply. Can be null.
|
|
755 |
*/
|
|
756 |
public Packet createClientResponse(Message msg) {
|
|
757 |
Packet response = new Packet(this);
|
|
758 |
response.soapAction = null; // de-initializing
|
|
759 |
response.setMessage(msg);
|
|
760 |
return response;
|
|
761 |
}
|
|
762 |
|
|
763 |
/**
|
|
764 |
* Creates a server-side response {@link Packet} from a request
|
|
765 |
* packet ({@code this}). If WS-Addressing is enabled, a default Action
|
|
766 |
* Message Addressing Property is obtained using <code>wsdlPort</code> {@link WSDLPort}
|
|
767 |
* and <code>binding</code> {@link WSBinding}.
|
|
768 |
* <p><p>
|
|
769 |
* This method should be called to create application response messages
|
|
770 |
* since they are associated with a {@link WSBinding} and {@link WSDLPort}.
|
|
771 |
* For creating protocol messages that require a non-default Action, use
|
|
772 |
* {@link #createServerResponse(Message, com.sun.xml.internal.ws.api.addressing.AddressingVersion, com.sun.xml.internal.ws.api.SOAPVersion, String)}.
|
|
773 |
*
|
|
774 |
* @param responseMessage The {@link Message} that represents a reply. Can be null.
|
|
775 |
* @param wsdlPort The response WSDL port.
|
|
776 |
* @param binding The response Binding. Cannot be null.
|
|
777 |
* @return response packet
|
|
778 |
*/
|
|
779 |
public Packet createServerResponse(@Nullable Message responseMessage, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
|
|
780 |
Packet r = createClientResponse(responseMessage);
|
|
781 |
|
|
782 |
AddressingVersion av = binding.getAddressingVersion();
|
|
783 |
// populate WS-A headers only if WS-A is enabled
|
|
784 |
if (av == null)
|
|
785 |
return r;
|
|
786 |
//populate WS-A headers only if the request has addressing headers
|
|
787 |
String inputAction = this.getMessage().getHeaders().getAction(av, binding.getSOAPVersion());
|
|
788 |
if (inputAction == null) {
|
|
789 |
return r;
|
|
790 |
}
|
|
791 |
// if one-way, then dont populate any WS-A headers
|
|
792 |
if (responseMessage == null || (wsdlPort != null && message.isOneWay(wsdlPort)))
|
|
793 |
return r;
|
|
794 |
|
|
795 |
// otherwise populate WS-Addressing headers
|
|
796 |
populateAddressingHeaders(binding, r, wsdlPort, seiModel);
|
|
797 |
return r;
|
|
798 |
}
|
|
799 |
|
|
800 |
|
|
801 |
public Packet relateServerResponse(@Nullable Packet r, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
|
|
802 |
copySatelliteInto((DistributedPropertySet) r);
|
|
803 |
r.soapAction = null;
|
|
804 |
r.handlerConfig = this.handlerConfig;
|
|
805 |
r.invocationProperties.putAll(this.invocationProperties);
|
|
806 |
r.handlerScopePropertyNames = this.handlerScopePropertyNames;
|
|
807 |
r.contentNegotiation = this.contentNegotiation;
|
|
808 |
r.wasTransportSecure = this.wasTransportSecure;
|
|
809 |
r.endpointAddress = this.endpointAddress;
|
|
810 |
r.wsdlOperation = this.wsdlOperation;
|
|
811 |
|
|
812 |
r.acceptableMimeTypes = this.acceptableMimeTypes;
|
|
813 |
r.endpoint = this.endpoint;
|
|
814 |
r.proxy = this.proxy;
|
|
815 |
r.webServiceContextDelegate = this.webServiceContextDelegate;
|
|
816 |
r.expectReply = this.expectReply;
|
|
817 |
|
|
818 |
AddressingVersion av = binding.getAddressingVersion();
|
|
819 |
// populate WS-A headers only if WS-A is enabled
|
|
820 |
if (av == null)
|
|
821 |
return r;
|
|
822 |
//populate WS-A headers only if the request has addressing headers
|
|
823 |
String inputAction = this.getMessage().getHeaders().getAction(av, binding.getSOAPVersion());
|
|
824 |
if (inputAction == null) {
|
|
825 |
return r;
|
|
826 |
}
|
|
827 |
// if one-way, then dont populate any WS-A headers
|
|
828 |
if (r.getMessage() == null || (wsdlPort != null && message.isOneWay(wsdlPort)))
|
|
829 |
return r;
|
|
830 |
|
|
831 |
// otherwise populate WS-Addressing headers
|
|
832 |
populateAddressingHeaders(binding, r, wsdlPort, seiModel);
|
|
833 |
return r;
|
|
834 |
}
|
|
835 |
|
|
836 |
/**
|
|
837 |
* Creates a server-side response {@link Packet} from a request
|
|
838 |
* packet ({@code this}). If WS-Addressing is enabled, <code>action</code>
|
|
839 |
* is used as Action Message Addressing Property.
|
|
840 |
* <p><p>
|
|
841 |
* This method should be called only for creating protocol response messages
|
|
842 |
* that require a particular value of Action since they are not associated
|
|
843 |
* with a {@link WSBinding} and {@link WSDLPort} but do know the {@link AddressingVersion}
|
|
844 |
* and {@link SOAPVersion}.
|
|
845 |
*
|
|
846 |
* @param responseMessage The {@link Message} that represents a reply. Can be null.
|
|
847 |
* @param addressingVersion The WS-Addressing version of the response message.
|
|
848 |
* @param soapVersion The SOAP version of the response message.
|
|
849 |
* @param action The response Action Message Addressing Property value.
|
|
850 |
* @return response packet
|
|
851 |
*/
|
|
852 |
public Packet createServerResponse(@Nullable Message responseMessage, @NotNull AddressingVersion addressingVersion, @NotNull SOAPVersion soapVersion, @NotNull String action) {
|
|
853 |
Packet responsePacket = createClientResponse(responseMessage);
|
|
854 |
|
|
855 |
// populate WS-A headers only if WS-A is enabled
|
|
856 |
if (addressingVersion == null)
|
|
857 |
return responsePacket;
|
|
858 |
//populate WS-A headers only if the request has addressing headers
|
|
859 |
String inputAction = this.getMessage().getHeaders().getAction(addressingVersion, soapVersion);
|
|
860 |
if (inputAction == null) {
|
|
861 |
return responsePacket;
|
|
862 |
}
|
|
863 |
|
|
864 |
populateAddressingHeaders(responsePacket, addressingVersion, soapVersion, action, false);
|
|
865 |
return responsePacket;
|
|
866 |
}
|
|
867 |
|
|
868 |
/**
|
|
869 |
* Overwrites the {@link Message} of the response packet ({@code this}) by the given {@link Message}.
|
|
870 |
* Unlike {@link #setMessage(Message)}, fill in the addressing headers correctly, and this process
|
|
871 |
* requires the access to the request packet.
|
|
872 |
*
|
|
873 |
* <p>
|
|
874 |
* This method is useful when the caller needs to swap a response message completely to a new one.
|
|
875 |
*
|
|
876 |
* @see #createServerResponse(Message, AddressingVersion, SOAPVersion, String)
|
|
877 |
*/
|
|
878 |
public void setResponseMessage(@NotNull Packet request, @Nullable Message responseMessage, @NotNull AddressingVersion addressingVersion, @NotNull SOAPVersion soapVersion, @NotNull String action) {
|
|
879 |
Packet temp = request.createServerResponse(responseMessage, addressingVersion, soapVersion, action);
|
|
880 |
setMessage(temp.getMessage());
|
|
881 |
}
|
|
882 |
|
|
883 |
private void populateAddressingHeaders(Packet responsePacket, AddressingVersion av, SOAPVersion sv, String action, boolean mustUnderstand) {
|
|
884 |
// populate WS-A headers only if WS-A is enabled
|
|
885 |
if (av == null) return;
|
|
886 |
|
|
887 |
// if one-way, then dont populate any WS-A headers
|
|
888 |
if (responsePacket.getMessage() == null)
|
|
889 |
return;
|
|
890 |
|
|
891 |
HeaderList hl = responsePacket.getMessage().getHeaders();
|
|
892 |
|
|
893 |
WsaPropertyBag wpb = getSatellite(WsaPropertyBag.class);
|
|
894 |
|
|
895 |
// wsa:To
|
|
896 |
WSEndpointReference replyTo = null;
|
|
897 |
if (wpb != null)
|
|
898 |
replyTo = wpb.getReplyToFromRequest();
|
|
899 |
if (replyTo == null)
|
|
900 |
replyTo = message.getHeaders().getReplyTo(av, sv);
|
|
901 |
|
|
902 |
// wsa:Action, add if the message doesn't already contain it,
|
|
903 |
// generally true for SEI case where there is SEIModel or WSDLModel
|
|
904 |
// false for Provider with no wsdl, Expects User to set the coresponding header on the Message.
|
|
905 |
if (responsePacket.getMessage().getHeaders().getAction(av, sv) == null) {
|
|
906 |
//wsa:Action header is not set in the message, so use the wsa:Action passed as the parameter.
|
|
907 |
hl.add(new StringHeader(av.actionTag, action, sv, mustUnderstand));
|
|
908 |
}
|
|
909 |
|
|
910 |
// wsa:MessageID
|
|
911 |
if (responsePacket.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
|
|
912 |
// if header doesn't exist, method getID creates a new random id
|
|
913 |
String newID = Message.generateMessageID();
|
|
914 |
hl.add(new StringHeader(av.messageIDTag, newID));
|
|
915 |
}
|
|
916 |
|
|
917 |
// wsa:RelatesTo
|
|
918 |
String mid = null;
|
|
919 |
if (wpb != null)
|
|
920 |
mid = wpb.getMessageID();
|
|
921 |
if (mid == null)
|
|
922 |
mid = message.getHeaders().getMessageID(av, sv);
|
|
923 |
if (mid != null)
|
|
924 |
hl.add(new RelatesToHeader(av.relatesToTag, mid));
|
|
925 |
|
|
926 |
|
|
927 |
// populate reference parameters
|
|
928 |
WSEndpointReference refpEPR = null;
|
|
929 |
if (responsePacket.getMessage().isFault()) {
|
|
930 |
// choose FaultTo
|
|
931 |
if (wpb != null)
|
|
932 |
refpEPR = wpb.getFaultToFromRequest();
|
|
933 |
if (refpEPR == null)
|
|
934 |
refpEPR = message.getHeaders().getFaultTo(av, sv);
|
|
935 |
// if FaultTo is null, then use ReplyTo
|
|
936 |
if (refpEPR == null)
|
|
937 |
refpEPR = replyTo;
|
|
938 |
} else {
|
|
939 |
// choose ReplyTo
|
|
940 |
refpEPR = replyTo;
|
|
941 |
}
|
|
942 |
if (refpEPR != null) {
|
|
943 |
hl.add(new StringHeader(av.toTag, refpEPR.getAddress()));
|
|
944 |
refpEPR.addReferenceParametersToList(hl);
|
|
945 |
}
|
|
946 |
}
|
|
947 |
|
|
948 |
private void populateAddressingHeaders(WSBinding binding, Packet responsePacket, WSDLPort wsdlPort, SEIModel seiModel) {
|
|
949 |
AddressingVersion addressingVersion = binding.getAddressingVersion();
|
|
950 |
|
|
951 |
if (addressingVersion == null) return;
|
|
952 |
|
|
953 |
WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, seiModel, binding);
|
|
954 |
String action = responsePacket.message.isFault() ?
|
|
955 |
wsaHelper.getFaultAction(this, responsePacket) :
|
|
956 |
wsaHelper.getOutputAction(this);
|
|
957 |
if (action == null) {
|
|
958 |
LOGGER.info("WSA headers are not added as value for wsa:Action cannot be resolved for this message");
|
|
959 |
return;
|
|
960 |
}
|
|
961 |
populateAddressingHeaders(responsePacket, addressingVersion, binding.getSOAPVersion(), action, addressingVersion.isRequired(binding));
|
|
962 |
}
|
|
963 |
|
|
964 |
public String toShortString() {
|
|
965 |
return super.toString();
|
|
966 |
}
|
|
967 |
|
|
968 |
// For use only in a debugger
|
|
969 |
public String toString() {
|
|
970 |
StringBuilder buf = new StringBuilder();
|
|
971 |
buf.append(super.toString());
|
|
972 |
String content;
|
|
973 |
try {
|
|
974 |
if (message != null) {
|
|
975 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
976 |
XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
|
|
977 |
message.copy().writeTo(xmlWriter);
|
|
978 |
xmlWriter.flush();
|
|
979 |
xmlWriter.close();
|
|
980 |
baos.flush();
|
|
981 |
XMLStreamWriterFactory.recycle(xmlWriter);
|
|
982 |
|
|
983 |
byte[] bytes = baos.toByteArray();
|
|
984 |
//message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
|
|
985 |
content = new String(bytes, "UTF-8");
|
|
986 |
} else {
|
|
987 |
content = "<none>";
|
|
988 |
}
|
|
989 |
} catch (Throwable t) {
|
|
990 |
throw new WebServiceException(t);
|
|
991 |
}
|
|
992 |
buf.append(" Content: ").append(content);
|
|
993 |
return buf.toString();
|
|
994 |
}
|
|
995 |
|
|
996 |
// completes TypedMap
|
|
997 |
private static final PropertyMap model;
|
|
998 |
|
|
999 |
static {
|
|
1000 |
model = parse(Packet.class);
|
|
1001 |
}
|
|
1002 |
|
|
1003 |
protected PropertyMap getPropertyMap() {
|
|
1004 |
return model;
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
private static final Logger LOGGER = Logger.getLogger(Packet.class.getName());
|
|
1008 |
|
|
1009 |
public SOAPMessage getSOAPMessage() throws SOAPException {
|
|
1010 |
return (message != null) ? message.readAsSOAPMessage() : null;
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
Codec codec = null;
|
|
1014 |
Codec getCodec() {
|
|
1015 |
if (codec != null) return codec;
|
|
1016 |
if (endpoint != null) {
|
|
1017 |
codec = endpoint.createCodec();
|
|
1018 |
}
|
|
1019 |
WSBinding wsb = getBinding();
|
|
1020 |
if (wsb != null) {
|
|
1021 |
codec = wsb.getBindingId().createEncoder(wsb);
|
|
1022 |
}
|
|
1023 |
return codec;
|
|
1024 |
}
|
|
1025 |
|
|
1026 |
|
|
1027 |
public ContentType writeTo( OutputStream out ) throws IOException {
|
|
1028 |
return getCodec().encode(this, out);
|
|
1029 |
}
|
|
1030 |
|
|
1031 |
public ContentType writeTo( WritableByteChannel buffer ) {
|
|
1032 |
return getCodec().encode(this, buffer);
|
|
1033 |
}
|
|
1034 |
}
|