/* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.xml.internal.ws.api.message; import com.oracle.webservices.internal.api.message.ContentType; import com.oracle.webservices.internal.api.message.PropertySet; import com.sun.istack.internal.NotNull; import com.sun.istack.internal.Nullable; import com.sun.xml.internal.bind.marshaller.SAX2DOMEx; import com.sun.xml.internal.ws.addressing.WsaPropertyBag; import com.sun.xml.internal.ws.addressing.WsaServerTube; import com.sun.xml.internal.ws.addressing.WsaTubeHelper; import com.sun.xml.internal.ws.api.Component; import com.sun.xml.internal.ws.api.EndpointAddress; import com.sun.xml.internal.ws.api.SOAPVersion; import com.sun.xml.internal.ws.api.WSBinding; import com.sun.xml.internal.ws.api.addressing.AddressingVersion; import com.sun.xml.internal.ws.api.addressing.WSEndpointReference; import com.sun.xml.internal.ws.api.model.JavaMethod; import com.sun.xml.internal.ws.api.model.SEIModel; import com.sun.xml.internal.ws.api.model.WSDLOperationMapping; import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation; import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; import com.sun.xml.internal.ws.api.pipe.Codec; import com.sun.xml.internal.ws.api.pipe.Tube; import com.sun.xml.internal.ws.api.server.Adapter; import com.sun.xml.internal.ws.api.server.TransportBackChannel; import com.sun.xml.internal.ws.api.server.WSEndpoint; import com.sun.xml.internal.ws.api.server.WebServiceContextDelegate; import com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory; import com.sun.xml.internal.ws.client.*; import com.sun.xml.internal.ws.developer.JAXWSProperties; import com.sun.xml.internal.ws.encoding.MtomCodec; import com.sun.xml.internal.ws.message.RelatesToHeader; import com.sun.xml.internal.ws.message.StringHeader; import com.sun.xml.internal.ws.util.DOMUtil; import com.sun.xml.internal.ws.util.xml.XmlUtil; import com.sun.xml.internal.ws.wsdl.DispatchException; import com.sun.xml.internal.ws.wsdl.OperationDispatcher; import com.sun.xml.internal.ws.resources.AddressingMessages; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; import javax.xml.namespace.QName; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamException; import javax.xml.ws.BindingProvider; import javax.xml.ws.Dispatch; import javax.xml.ws.WebServiceContext; import javax.xml.ws.WebServiceException; import javax.xml.ws.handler.LogicalMessageContext; import javax.xml.ws.handler.MessageContext; import javax.xml.ws.handler.soap.SOAPMessageContext; import javax.xml.ws.soap.MTOMFeature; import java.util.*; import java.util.logging.Logger; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.channels.WritableByteChannel; /** * Represents a container of a {@link Message}. * *
* A packet can be thought of as a frame/envelope/package that wraps * a {@link Message}. A packet keeps track of optional metadata (properties) * about a {@link Message} that doesn't go across the wire. * This roughly corresponds to {@link MessageContext} in the JAX-WS API. * *
* Usually a packet contains a {@link Message} in it, but sometimes * (such as for a reply of an one-way operation), a packet may * float around without a {@link Message} in it. * * * *
* Information frequently used inside the JAX-WS RI * is stored in the strongly-typed fields. Other information is stored * in terms of a generic {@link Map} (see * {@link #invocationProperties}.) * *
* Some properties need to be retained between request and response, * some don't. For strongly typed fields, this characteristic is * statically known for each of them, and propagation happens accordingly. * For generic information stored in {@link Map}, {@link #invocationProperties} * stores per-invocation scope information (which carries over to * the response.) * *
* This object is used as the backing store of {@link MessageContext}, and * {@link LogicalMessageContext} and {@link SOAPMessageContext} will * be delegating to this object for storing/retrieving values. * * *
* {@link BindingProvider#getRequestContext() Request context} is used to * seed the initial values of {@link Packet}. * Some of those values go to strongly-typed fields, and others go to * {@link #invocationProperties}, as they need to be retained in the reply message. * *
* Similarly, {@link BindingProvider#getResponseContext() response context} * is constructed from {@link Packet} (or rather it's just a view of {@link Packet}.) * by using properties from {@link #invocationProperties}, * modulo properties named explicitly in {@link #getHandlerScopePropertyNames(boolean)}. * IOW, properties added to {@link #invocationProperties} * are exposed to the response context by default. * * * *
* This method should be only used to create a fresh {@link Packet}.
* To create a {@link Packet} for a reply, use {@link #createResponse(Message)}.
*
* @param request
* The request {@link Message}. Can be null.
*/
public Packet(Message request) {
this();
this.message = request;
if (message != null) message.setMessageMedadata(this);
}
/**
* Creates an empty {@link Packet} that doesn't have any {@link Message}.
*/
public Packet() {
this.invocationProperties = new HashMap
* This is a requirement from the security team.
*/
// TODO: expose this as a property
public boolean wasTransportSecure;
/**
* Inbound transport headers are captured in a transport neutral way.
* Transports are expected to fill this data after creating a Packet.
*
* {@link SOAPMessage#getMimeHeaders()} would return these headers.
*/
public static final String INBOUND_TRANSPORT_HEADERS = "com.sun.xml.internal.ws.api.message.packet.inbound.transport.headers";
/**
* Outbound transport headers are captured in a transport neutral way.
*
*
* Transports may choose to ignore certain headers that interfere with
* its correct operation, such as
* Content-Type and Content-Length.
*/
public static final String OUTBOUND_TRANSPORT_HEADERS = "com.sun.xml.internal.ws.api.message.packet.outbound.transport.headers";
/**
*
*/
public static final String HA_INFO = "com.sun.xml.internal.ws.api.message.packet.hainfo";
/**
* This property holds the snapshot of HandlerConfiguration
* at the time of invocation.
* This property is used by MUPipe and HandlerPipe implementations.
*/
@Property(BindingProviderProperties.JAXWS_HANDLER_CONFIG)
public HandlerConfiguration handlerConfig;
/**
* If a message originates from a proxy stub that implements
* a port interface, this field is set to point to that object.
*
* TODO: who's using this property?
*/
@Property(BindingProviderProperties.JAXWS_CLIENT_HANDLE_PROPERTY)
public BindingProvider proxy;
/**
* Determines if the governing {@link Adapter} or {@link com.sun.xml.internal.ws.api.pipe.Fiber.CompletionCallback}
* will handle delivering response messages targeted at non-anonymous endpoint
* addresses. Prior to the introduction of this flag
* the {@link WsaServerTube} would deliver non-anonymous responses.
*/
public boolean isAdapterDeliversNonAnonymousResponse;
/**
* During invocation of a client Stub or Dispatch a Packet is
* created then the Stub's RequestContext is copied into the
* Packet. On certain internal cases the Packet is created
* *before* the invocation. In those cases we want the contents
* of the Packet to take precedence when ever any key/value pairs
* collide : if the Packet contains a value for a key use it,
* otherwise copy as usual from Stub.
*/
public boolean packetTakesPriorityOverRequestContext = false;
/**
* The endpoint address to which this message is sent to.
*
*
* The JAX-WS spec allows this to be changed for each message,
* so it's designed to be a property.
*
*
* Must not be null for a request message on the client. Otherwise
* it's null.
*/
public EndpointAddress endpointAddress;
/**
* @deprecated
* The programatic acccess should be done via
* {@link #endpointAddress}. This is for JAX-WS client applications
* that access this property via {@link BindingProvider#ENDPOINT_ADDRESS_PROPERTY}.
*/
@Property(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)
public String getEndPointAddressString() {
if (endpointAddress == null) {
return null;
} else {
return endpointAddress.toString();
}
}
public void setEndPointAddressString(String s) {
if (s == null) {
this.endpointAddress = null;
} else {
this.endpointAddress = EndpointAddress.create(s);
}
}
/**
* The value of {@link ContentNegotiation#PROPERTY}
* property.
*
* Headers which have attribute wsa:IsReferenceParameter="true"
* This is not cached as one may reset the Message.
*
*/
@Property(MessageContext.REFERENCE_PARAMETERS)
public
@NotNull
List The representation shall be that specified by the HTTP Accept
* request-header field.
*
* The list of content types will be obtained from the transport
* meta-data of a inbound message in a request/response message exchange.
* Hence this property will be set by the service-side transport pipe.
*/
public String acceptableMimeTypes;
/**
* When non-null, this object is consulted to
* implement {@link WebServiceContext} methods
* exposed to the user application.
*
* Used only on the server side.
*
*
* This property is set from the parameter
* of {@link WSEndpoint.PipeHead#process}.
*/
public WebServiceContextDelegate webServiceContextDelegate;
/**
* Used only on the server side so that the transport
* can close the connection early.
*
*
* This field can be null. While a message is being processed,
* this field can be set explicitly to null, to prevent
* future pipes from closing a transport (see {@link #keepTransportBackChannelOpen()})
*
*
* This property is set from the parameter
* of {@link WSEndpoint.PipeHead#process}.
*/
public
@Nullable
TransportBackChannel transportBackChannel;
/**
* Keeps the transport back channel open (by seeting {@link #transportBackChannel} to null.)
*
* @return
* The previous value of {@link #transportBackChannel}.
*/
public TransportBackChannel keepTransportBackChannelOpen() {
TransportBackChannel r = transportBackChannel;
transportBackChannel = null;
return r;
}
/**
* The governing owner of this packet. On the service-side this is the {@link Adapter} and on the client it is the {@link Stub}.
*
*/
public Component component;
/**
* The governing {@link WSEndpoint} in which this message is floating.
*
*
* This property is set if and only if this is on the server side.
*/
@Property(JAXWSProperties.WSENDPOINT)
public WSEndpoint endpoint;
/**
* The value of the SOAPAction header associated with the message.
*
*
* For outgoing messages, the transport may sends out this value.
* If this field is null, the transport may choose to send ""
* (quoted empty string.)
*
* For incoming messages, the transport will set this field.
* If the incoming message did not contain the SOAPAction header,
* the transport sets this field to null.
*
*
* If the value is non-null, it must be always in the quoted form.
* The value can be null.
*
*
* Note that the way the transport sends this value out depends on
* transport and SOAP version.
*
* This property is used on the client-side for
* outbound messages, so that a pipeline
* can communicate to the terminal (or intermediate) {@link Tube}s
* about this knowledge.
*
*
* This property MUST NOT be used by 2-way transports
* that have the transport back channel. Those transports
* must always check a reply coming through the transport back
* channel regardless of this value, and act accordingly.
* (This is because the expectation of the client and
* that of the server can be different, for example because
* of a bug in user's configuration.)
*
*
* This property is for one-way transports, and more
* specifically for the coordinator that correlates sent requests
* and incoming replies, to decide whether to block
* until a response is received.
*
*
* Also note that this property is related to
* {@link WSDLOperation#isOneWay()} but not the same thing.
* In fact in general, they are completely orthogonal.
*
* For example, the calling application can choose to invoke
* {@link Dispatch#invoke(Object)} or {@link Dispatch#invokeOneWay(Object)}
* with an operation (which determines the value of this property),
* regardless of whether WSDL actually says it's one way or not.
* So these two booleans can take any combinations.
*
*
*
* When this property is {@link Boolean#FALSE}, it means that
* the pipeline does not expect a reply from a server (and therefore
* the correlator should not block for a reply message
* -- if such a reply does arrive, it can be just ignored.)
*
*
* When this property is {@link Boolean#TRUE}, it means that
* the pipeline expects a reply from a server (and therefore
* the correlator should block to see if a reply message is received,
*
*
* This property is always set to {@link Boolean#TRUE} or
* {@link Boolean#FALSE} when used on the request message
* on the client side.
* No other {@link Boolean} instances are allowed.
*
*
* In all other situations, this property is null.
*
*/
@Property(BindingProviderProperties.ONE_WAY_OPERATION)
public Boolean expectReply;
/**
* This property will be removed in a near future.
*
*
* A part of what this flag represented moved to
* {@link #expectReply} and the other part was moved
* to {@link Message#isOneWay(WSDLPort)}. Please update
* your code soon, or risk breaking your build!!
*/
@Deprecated
public Boolean isOneWay;
/**
* Indicates whether is invoking a synchronous pattern. If true, no
* async client programming model (e.g. AsyncResponse or AsyncHandler)
* were used to make the request that created this packet.
*/
public Boolean isSynchronousMEP;
/**
* Indicates whether a non-null AsyncHandler was given at the point of
* making the request that created this packet. This flag can be used
* by Tube implementations to decide how to react when isSynchronousMEP
* is false. If true, the client gave a non-null AsyncHandler instance
* at the point of request, and will be expecting a response on that
* handler when this request has been processed.
*/
public Boolean nonNullAsyncHandlerGiven;
/**
* USE-CASE:
* WS-AT is enabled, but there is no WSDL available.
* If Packet.isRequestReplyMEP() is Boolean.TRUE then WS-AT should
* add the TX context.
*
* This value is exposed to users via facades at higher abstraction layers.
* The user should NEVER use Packet directly.
* This value should ONLY be set by users.
*/
private Boolean isRequestReplyMEP;
public Boolean isRequestReplyMEP() { return isRequestReplyMEP; }
public void setRequestReplyMEP(final Boolean x) { isRequestReplyMEP = x; }
/**
* Lazily created set of handler-scope property names.
*
*
* We expect that this is only used when handlers are present
* and they explicitly set some handler-scope values.
*
* @see #getHandlerScopePropertyNames(boolean)
*/
private Set
* These properties are copied from a request to a response.
* This is where we keep properties that are set by handlers.
*
*
* See class javadoc for more discussion.
*
* @see #getHandlerScopePropertyNames(boolean)
*/
public final Map
* These properties will not be exposed to the response context.
* Consequently, if a {@link Tube} wishes to hide a property
* to {@link ResponseContext}, it needs to add the property name
* to this set.
*
* @param readOnly
* Return true if the caller only intends to read the value of this set.
* Internally, the {@link Set} is allocated lazily, and this flag helps
* optimizing the strategy.
*
* @return
* always non-null, possibly empty set that stores property names.
*/
public final Set
* When a {@link Packet} for a reply is created, some properties need to be
* copied over from a request to a response, and this method handles it correctly.
*
* @deprecated
* Use createClientResponse(Message) for client side and
* createServerResponse(Message, String) for server side response
* creation.
*
* @param msg
* The {@link Message} that represents a reply. Can be null.
*/
@Deprecated
public Packet createResponse(Message msg) {
Packet response = new Packet(this);
response.setMessage(msg);
return response;
}
/**
* Creates a response {@link Packet} from a request packet ({@code this}).
*
*
* When a {@link Packet} for a reply is created, some properties need to be
* copied over from a request to a response, and this method handles it correctly.
*
* @param msg
* The {@link Message} that represents a reply. Can be null.
*/
public Packet createClientResponse(Message msg) {
Packet response = new Packet(this);
response.setMessage(msg);
finishCreateRelateClientResponse(response);
return response;
}
/**
* For use cases that start with an existing Packet.
*/
public Packet relateClientResponse(final Packet response) {
response.relatePackets(this, true);
finishCreateRelateClientResponse(response);
return response;
}
private void finishCreateRelateClientResponse(final Packet response) {
response.soapAction = null; // de-initializing
response.setState(State.ClientResponse);
}
/**
* Creates a server-side response {@link Packet} from a request
* packet ({@code this}). If WS-Addressing is enabled, a default Action
* Message Addressing Property is obtained using
* This method should be called to create application response messages
* since they are associated with a {@link WSBinding} and {@link WSDLPort}.
* For creating protocol messages that require a non-default Action, use
* {@link #createServerResponse(Message, com.sun.xml.internal.ws.api.addressing.AddressingVersion, com.sun.xml.internal.ws.api.SOAPVersion, String)}.
*
* @param responseMessage The {@link Message} that represents a reply. Can be null.
* @param wsdlPort The response WSDL port.
* @param binding The response Binding. Cannot be null.
* @return response packet
*/
public Packet createServerResponse(@Nullable Message responseMessage, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
Packet r = createClientResponse(responseMessage);
return relateServerResponse(r, wsdlPort, seiModel, binding);
}
/**
* Copy all properties from ({@code this}) packet into a input {@link Packet}
* @param response packet
*/
public void copyPropertiesTo(@Nullable Packet response){
relatePackets(response, false);
}
/**
* A common method to make members related between input packet and this packet
*
* @param packet
* @param isCopy 'true' means copying all properties from input packet;
* 'false' means copying all properties from this packet to input packet.
*/
private void relatePackets(@Nullable Packet packet, boolean isCopy)
{
Packet request;
Packet response;
if (!isCopy) { //is relate
request = this;
response = packet;
// processing specific properties
response.soapAction = null;
response.invocationProperties.putAll(request.invocationProperties);
if (this.getState().equals(State.ServerRequest)) {
response.setState(State.ServerResponse);
}
} else { //is copy constructor
request = packet;
response = this;
// processing specific properties
response.soapAction = request.soapAction;
response.setState(request.getState());
}
request.copySatelliteInto(response);
response.isAdapterDeliversNonAnonymousResponse = request.isAdapterDeliversNonAnonymousResponse;
response.handlerConfig = request.handlerConfig;
response.handlerScopePropertyNames = request.handlerScopePropertyNames;
response.contentNegotiation = request.contentNegotiation;
response.wasTransportSecure = request.wasTransportSecure;
response.transportBackChannel = request.transportBackChannel;
response.endpointAddress = request.endpointAddress;
response.wsdlOperation = request.wsdlOperation;
response.wsdlOperationMapping = request.wsdlOperationMapping;
response.acceptableMimeTypes = request.acceptableMimeTypes;
response.endpoint = request.endpoint;
response.proxy = request.proxy;
response.webServiceContextDelegate = request.webServiceContextDelegate;
response.expectReply = request.expectReply;
response.component = request.component;
response.mtomAcceptable = request.mtomAcceptable;
response.mtomRequest = request.mtomRequest;
// copy other properties that need to be copied. is there any?
}
public Packet relateServerResponse(@Nullable Packet r, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
relatePackets(r, false);
r.setState(State.ServerResponse);
AddressingVersion av = binding.getAddressingVersion();
// populate WS-A headers only if WS-A is enabled
if (av == null) {
return r;
}
if (getMessage() == null) {
return r;
}
//populate WS-A headers only if the request has addressing headers
String inputAction = AddressingUtils.getAction(getMessage().getHeaders(), av, binding.getSOAPVersion());
if (inputAction == null) {
return r;
}
// if one-way, then dont populate any WS-A headers
if (r.getMessage() == null || (wsdlPort != null && getMessage().isOneWay(wsdlPort))) {
return r;
}
// otherwise populate WS-Addressing headers
populateAddressingHeaders(binding, r, wsdlPort, seiModel);
return r;
}
/**
* Creates a server-side response {@link Packet} from a request
* packet ({@code this}). If WS-Addressing is enabled,
* This method should be called only for creating protocol response messages
* that require a particular value of Action since they are not associated
* with a {@link WSBinding} and {@link WSDLPort} but do know the {@link AddressingVersion}
* and {@link SOAPVersion}.
*
* @param responseMessage The {@link Message} that represents a reply. Can be null.
* @param addressingVersion The WS-Addressing version of the response message.
* @param soapVersion The SOAP version of the response message.
* @param action The response Action Message Addressing Property value.
* @return response packet
*/
public Packet createServerResponse(@Nullable Message responseMessage, @NotNull AddressingVersion addressingVersion, @NotNull SOAPVersion soapVersion, @NotNull String action) {
Packet responsePacket = createClientResponse(responseMessage);
responsePacket.setState(State.ServerResponse);
// populate WS-A headers only if WS-A is enabled
if (addressingVersion == null) {
return responsePacket;
}
//populate WS-A headers only if the request has addressing headers
String inputAction = AddressingUtils.getAction(this.getMessage().getHeaders(), addressingVersion, soapVersion);
if (inputAction == null) {
return responsePacket;
}
populateAddressingHeaders(responsePacket, addressingVersion, soapVersion, action, false);
return responsePacket;
}
/**
* Overwrites the {@link Message} of the response packet ({@code this}) by the given {@link Message}.
* Unlike {@link #setMessage(Message)}, fill in the addressing headers correctly, and this process
* requires the access to the request packet.
*
*
* This method is useful when the caller needs to swap a response message completely to a new one.
*
* @see #createServerResponse(Message, AddressingVersion, SOAPVersion, String)
*/
public void setResponseMessage(@NotNull Packet request, @Nullable Message responseMessage, @NotNull AddressingVersion addressingVersion, @NotNull SOAPVersion soapVersion, @NotNull String action) {
Packet temp = request.createServerResponse(responseMessage, addressingVersion, soapVersion, action);
setMessage(temp.getMessage());
}
private void populateAddressingHeaders(Packet responsePacket, AddressingVersion av, SOAPVersion sv, String action, boolean mustUnderstand) {
// populate WS-A headers only if WS-A is enabled
if (av == null) return;
// if one-way, then dont populate any WS-A headers
if (responsePacket.getMessage() == null)
return;
MessageHeaders hl = responsePacket.getMessage().getHeaders();
WsaPropertyBag wpb = getSatellite(WsaPropertyBag.class);
Message msg = getMessage();
// wsa:To
WSEndpointReference replyTo = null;
Header replyToFromRequestMsg = AddressingUtils.getFirstHeader(msg.getHeaders(), av.replyToTag, true, sv);
Header replyToFromResponseMsg = hl.get(av.toTag, false);
boolean replaceToTag = true;
try{
if (replyToFromRequestMsg != null){
replyTo = replyToFromRequestMsg.readAsEPR(av);
}
if (replyToFromResponseMsg != null && replyTo == null) {
replaceToTag = false;
}
} catch (XMLStreamException e) {
throw new WebServiceException(AddressingMessages.REPLY_TO_CANNOT_PARSE(), e);
}
if (replyTo == null) {
replyTo = AddressingUtils.getReplyTo(msg.getHeaders(), av, sv);
}
// wsa:Action, add if the message doesn't already contain it,
// generally true for SEI case where there is SEIModel or WSDLModel
// false for Provider with no wsdl, Expects User to set the coresponding header on the Message.
if (AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), av, sv) == null) {
//wsa:Action header is not set in the message, so use the wsa:Action passed as the parameter.
hl.add(new StringHeader(av.actionTag, action, sv, mustUnderstand));
}
// wsa:MessageID
if (responsePacket.getMessage().getHeaders().get(av.messageIDTag, false) == null) {
// if header doesn't exist, method getID creates a new random id
String newID = Message.generateMessageID();
hl.add(new StringHeader(av.messageIDTag, newID));
}
// wsa:RelatesTo
String mid = null;
if (wpb != null) {
mid = wpb.getMessageID();
}
if (mid == null) {
mid = AddressingUtils.getMessageID(msg.getHeaders(), av, sv);
}
if (mid != null) {
hl.addOrReplace(new RelatesToHeader(av.relatesToTag, mid));
}
// populate reference parameters
WSEndpointReference refpEPR = null;
if (responsePacket.getMessage().isFault()) {
// choose FaultTo
if (wpb != null) {
refpEPR = wpb.getFaultToFromRequest();
}
if (refpEPR == null) {
refpEPR = AddressingUtils.getFaultTo(msg.getHeaders(), av, sv);
}
// if FaultTo is null, then use ReplyTo
if (refpEPR == null) {
refpEPR = replyTo;
}
} else {
// choose ReplyTo
refpEPR = replyTo;
}
if (replaceToTag && refpEPR != null) {
hl.addOrReplace(new StringHeader(av.toTag, refpEPR.getAddress()));
refpEPR.addReferenceParametersToList(hl);
}
}
private void populateAddressingHeaders(WSBinding binding, Packet responsePacket, WSDLPort wsdlPort, SEIModel seiModel) {
AddressingVersion addressingVersion = binding.getAddressingVersion();
if (addressingVersion == null) {
return;
}
WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, seiModel, binding);
String action = responsePacket.getMessage().isFault() ?
wsaHelper.getFaultAction(this, responsePacket) :
wsaHelper.getOutputAction(this);
if (action == null) {
LOGGER.info("WSA headers are not added as value for wsa:Action cannot be resolved for this message");
return;
}
populateAddressingHeaders(responsePacket, addressingVersion, binding.getSOAPVersion(), action, AddressingVersion.isRequired(binding));
}
public String toShortString() {
return super.toString();
}
// For use only in a debugger
@Override
public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(super.toString());
String content;
try {
Message msg = getMessage();
if (msg != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
msg.copy().writeTo(xmlWriter);
xmlWriter.flush();
xmlWriter.close();
baos.flush();
XMLStreamWriterFactory.recycle(xmlWriter);
byte[] bytes = baos.toByteArray();
//message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
content = new String(bytes, "UTF-8");
} else {
content = "wsdlPort
{@link WSDLPort}
* and binding
{@link WSBinding}.
* action
* is used as Action Message Addressing Property.
*