boolean outOnlyMessage = "true".equals(
synapseOutMessageContext.getProperty(SynapseConstants.OUT_ONLY));
// get a reference to the DYNAMIC operation of the Anonymous Axis2 service
AxisOperation axisAnonymousOperation = anoymousService.getOperation(
outOnlyMessage ?
new QName(AnonymousServiceFactory.OUT_ONLY_OPERATION) :
new QName(AnonymousServiceFactory.OUT_IN_OPERATION));
Options clientOptions = new Options();
clientOptions.setUseSeparateListener(separateListener);
// if RM is requested,
if (wsRMEnabled) {
// if a WS-RM policy is specified, use it
if (wsRMPolicyKey != null) {
clientOptions.setProperty(
SynapseConstants.SANDESHA_POLICY,
getPolicy(synapseOutMessageContext, wsRMPolicyKey));
}
copyRMOptions(originalInMsgCtx, clientOptions);
}
// if security is enabled,
if (wsSecurityEnabled) {
// if a WS-Sec policy is specified, use it
if (wsSecPolicyKey != null) {
clientOptions.setProperty(
SynapseConstants.RAMPART_POLICY,
getPolicy(synapseOutMessageContext, wsSecPolicyKey));
}
// temporary workaround for https://issues.apache.org/jira/browse/WSCOMMONS-197
if (axisOutMsgCtx.getEnvelope().getHeader() == null) {
SOAPFactory fac = axisOutMsgCtx.isSOAP11() ?
OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory();
fac.createSOAPHeader(axisOutMsgCtx.getEnvelope());
}
}
OperationClient mepClient = axisAnonymousOperation.createClient(serviceCtx, clientOptions);
mepClient.addMessageContext(axisOutMsgCtx);
axisOutMsgCtx.setAxisMessage(
axisAnonymousOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
if (!outOnlyMessage) {
// always set a callback as we decide if the send it blocking or non blocking within
// the MEP client. This does not cause an overhead, as we simply create a 'holder'
// object with a reference to the outgoing synapse message context