*
*/
public void invokeOneWay(Object obj) throws WebServiceException {
// All exceptions are caught and rethrown as a WebServiceException
MessageContext requestMsgCtx = null;
try {
if (log.isDebugEnabled()) {
log.debug("Entered one-way invocation: BaseDispatch.invokeOneWay()");
}
// Create the InvocationContext instance for this request/response flow.
InvocationContext invocationContext =
InvocationContextFactory.createInvocationContext(null);
invocationContext.setServiceClient(serviceClient);
// Create the MessageContext to hold the actual request message and its
// associated properties
requestMsgCtx = new MessageContext();
requestMsgCtx.getAxisMessageContext().setProperty(BINDING_PROVIDER, this);
requestMsgCtx.setEndpointDescription(getEndpointDescription());
invocationContext.setRequestMessageContext(requestMsgCtx);
/*
* TODO: review: make sure the handlers are set on the InvocationContext
* This implementation of the JAXWS runtime does not use Endpoint, which
* would normally be the place to initialize and store the handler list.
* In lieu of that, we will have to intialize and store them on the
* InvocationContext. also see the InvocationContextFactory. On the client
* side, the binding is not yet set when we call into that factory, so the
* handler list doesn't get set on the InvocationContext object there. Thus
* we gotta do it here.
*/
// be sure to use whatever handlerresolver is registered on the Service
Binding binding = (Binding) getBinding();
invocationContext.setHandlers(binding.getHandlerChain());
initMessageContext(obj, requestMsgCtx);
/*
* if SESSION_MAINTAIN_PROPERTY is true, and the client app has explicitly set a HEADER_COOKIE on the request context, assume the client
* app is expecting the HEADER_COOKIE to be the session id. If we were establishing a new session, no cookie would be sent, and the
* server would reply with a "Set-Cookie" header, which is copied as a "Cookie"-keyed property to the service context during response.
* In this case, if we succeed in using an existing server session, no "Set-Cookie" header will be returned, and therefore no
* "Cookie"-keyed property would be set on the service context. So, let's copy our request context HEADER_COOKIE key to the service
* context now to prevent the "no cookie" exception in BindingProvider.setupSessionContext. It is possible the server does not support
* sessions, in which case no error occurs, but the client app would assume it is participating in a session.
*/
if ((requestContext.containsKey(BindingProvider.SESSION_MAINTAIN_PROPERTY)) && ((Boolean)requestContext.get(BindingProvider.SESSION_MAINTAIN_PROPERTY))) {
if ((requestContext.containsKey(HTTPConstants.HEADER_COOKIE)) && (requestContext.get(HTTPConstants.HEADER_COOKIE) != null)) {
if (invocationContext.getServiceClient().getServiceContext().getProperty(HTTPConstants.HEADER_COOKIE) == null) {
invocationContext.getServiceClient().getServiceContext().setProperty(HTTPConstants.HEADER_COOKIE, requestContext.get(HTTPConstants.HEADER_COOKIE));
if (log.isDebugEnabled()) {
log.debug("Client-app defined Cookie property (assume to be session cookie) on request context copied to service context." +
" Caution: server may or may not support sessions, but client app will not be informed when not supported.");
}
}
}
}
// call common init method for all invoke* paths
preInvokeInit(invocationContext);
// Migrate the properties from the client request context bag to
// the request MessageContext.
ApplicationContextMigratorUtil.performMigrationToMessageContext(
Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID,
getRequestContext(), requestMsgCtx);
// Perform the WebServiceFeature configuration requested by the user.
binding.configure(requestMsgCtx, this);
// Initializing the message context above will put the outbound message onto the messageContext
// Determine the operation if possible from the outbound message. If it can not be determined
// it will be set to null. In this case, an anonymous operation will be used. Note that determining
// the operation will mean deserializing the message. That means that any WebServiceFeatures must have
// been configured first so that any relevant configurations (such as MTOM) have been initialized prior to
// the message being deserialized. This is particularly true for Dispatch<JAXB Element>.
requestMsgCtx.setOperationDescription(getOperationDescriptionForDispatch(requestMsgCtx));
// Send the request using the InvocationController
ic.invokeOneWay(invocationContext);
//Check to see if we need to maintain session state
checkMaintainSessionState(requestMsgCtx, invocationContext);
if (log.isDebugEnabled()) {
log.debug("One-way invocation completed: BaseDispatch.invokeOneWay()");
}
return;
} catch (WebServiceException e) {
if (log.isDebugEnabled()) {
log.debug("BaseDispatch.invokeOneWay(): One-way invocation failed, " +
"caught a WebServiceException: ", e);
}
throw e;
} catch (Exception e) {
// All exceptions are caught and rethrown as a WebServiceException
if (log.isDebugEnabled()) {
log.debug("BaseDispatch.invokeOneWay(): One-way invocation failed, " +
"caught an Exception, wrapping into a WebServicesException. " +
" Exception caught: ", e);
}
throw ExceptionFactory.makeWebServiceException(e);
} finally {
// In all other cases we rely on freeInputStream to perform the clean up. Since we don't expect
// a response in the invokeOneWay case, we need to perform call TransportSender#cleanup explicitly
try {
if (requestMsgCtx != null && requestMsgCtx.getAxisMessageContext() != null) {
org.apache.axis2.context.MessageContext axisMsgCtx = requestMsgCtx.getAxisMessageContext();
if (axisMsgCtx.getTransportOut() != null && axisMsgCtx.getTransportOut().getSender() != null) {
axisMsgCtx.getTransportOut().getSender().cleanup(axisMsgCtx);
}
}
} catch (Exception ignore) {