public static void sendAckRequest(ServiceClient serviceClient) throws SandeshaException {
setUpServiceClientAnonymousOperations (serviceClient);
Options options = serviceClient.getOptions();
if (options == null)
throw new SandeshaException(SandeshaMessageHelper.getMessage(
SandeshaMessageKeys.optionsObjectNotSet));
ServiceContext serviceContext = serviceClient.getServiceContext();
if (serviceContext == null)
throw new SandeshaException(SandeshaMessageHelper.getMessage(
SandeshaMessageKeys.serviceContextNotSet));
ConfigurationContext configContext = serviceContext.getConfigurationContext();
String rmSpecVersion = (String) options.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
if (rmSpecVersion == null)
rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
if (Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(rmSpecVersion)) {
throw new SandeshaException(SandeshaMessageHelper.getMessage(
SandeshaMessageKeys.emptyAckRequestSpecLevel, rmSpecVersion));
}
String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
SOAPEnvelope dummyEnvelope = configureAckRequest(options, configContext);
OMElement ackRequestedHeaderBlock = dummyEnvelope.getHeader().getFirstChildWithName(
new QName(rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.ACK_REQUESTED));
String oldAction = options.getAction();
serviceClient.addHeader(ackRequestedHeaderBlock);
try {
//to inform the sandesha2 out handler
serviceClient.fireAndForget (null);
} catch (AxisFault e) {
String message = SandeshaMessageHelper.getMessage(
SandeshaMessageKeys.cannotSendAckRequestException, e.toString());
throw new SandeshaException(message, e);
}
serviceClient.removeHeaders();
options.setAction(oldAction);
}