// Get the order of pre/post handlerchains
HandlerType[] handlerType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };
HandlerType[] faultType = new HandlerType[] { HandlerType.PRE, HandlerType.ENDPOINT, HandlerType.POST };
// Associate a message context with the current thread
CommonMessageContext msgContext = new SOAPMessageContextJAXWS();
MessageContextAssociation.pushMessageContext(msgContext);
msgContext.setEndpointMetaData(epMetaData);
msgContext.setSOAPMessage(reqMsg);
msgContext.putAll(reqContext);
// The contents of the request context are used to initialize the message context (see section 9.4.1)
// prior to invoking any handlers (see chapter 9) for the outbound message. Each property within the
// request context is copied to the message context with a scope of HANDLER.
msgContext.put(MessageContextJAXWS.MESSAGE_OUTBOUND_PROPERTY, Boolean.TRUE);
QName portName = epMetaData.getPortName();
try
{
// Call the request handlers
boolean handlerPass = callRequestHandlerChain(portName, handlerType[0]);
handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[1]);
handlerPass = handlerPass && callRequestHandlerChain(portName, handlerType[2]);
XOPContext.visitAndRestoreXOPData();
// Handlers might have replaced the message
reqMsg = (SOAPMessageImpl)msgContext.getSOAPMessage();
MessageAbstraction resMsg = null;
if (handlerPass)
{
Map<String, Object> callProps = new HashMap<String, Object>(getRequestContext());
if (callProps.containsKey(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)) {
targetAddress = (String) callProps.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
}
EndpointInfo epInfo = new EndpointInfo(epMetaData, targetAddress, callProps);
resMsg = getRemotingConnection().invoke(reqMsg, epInfo, false);
//Pivot, switch to response ctx and save the response message there
msgContext = MessageContextJAXWS.processPivot(msgContext);
msgContext.setMessageAbstraction(resMsg);
// Call the response handler chain, removing the fault type entry will not call handleFault for that chain
handlerPass = callResponseHandlerChain(portName, handlerType[2]);
faultType[2] = null;
handlerPass = handlerPass && callResponseHandlerChain(portName, handlerType[1]);