String callbackAddress = null;
String callbackID = null;
Object conversationID = null;
// create a message object and set the args as its body
Message msg = messageFactory.createMessage();
msg.setBody(args);
msg.setOperation(op);
//FIXME: can we use the Axis2 addressing support for this?
SOAPHeader header = inMC.getEnvelope().getHeader();
if (header != null) {
OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM);
if (from != null) {
OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS);
if (callbackAddrElement != null) {
if (contract.getInterfaceContract().getCallbackInterface() != null) {
callbackAddress = callbackAddrElement.getText();
}
}
OMElement params = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS);
if (params != null) {
OMElement convIDElement =
params.getFirstChildWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN);
if (convIDElement != null) {
if (isConversational()) {
conversationID = convIDElement.getText();
}
}
OMElement callbackIDElement =
params.getFirstChildWithName(Axis2BindingInvoker.CALLBACK_ID_REFPARM_QN);
if (callbackIDElement != null) {
callbackID = callbackIDElement.getText();
}
}
}
// get policy specified headers
for (Axis2HeaderPolicy policy : axis2HeaderPolicies){
//Axis2BindingHeaderConfigurator.getHeader(inMC, msg, policy.getHeaderName());
}
if (axis2TokenAuthenticationPolicy != null) {
Axis2SOAPHeaderString tokenHeader = new Axis2SOAPHeaderString();
Axis2BindingHeaderConfigurator.getHeader(inMC,
msg,
axis2TokenAuthenticationPolicy.getTokenName(),
tokenHeader);
}
}
//fill message with QoS context info
fillQoSContext(msg, inMC);
// if reference parameters are needed, create a new "From" EPR to hold them
EndpointReference from = null;
ReferenceParameters parameters = null;
if (callbackAddress != null ||
callbackID != null ||
conversationID != null) {
from = createEndpointReference(null);
parameters = from.getReferenceParameters();
msg.setFrom(from);
}
// set the reference parameters into the "From" EPR
if (callbackAddress != null) {
parameters.setCallbackReference(createEndpointReference(callbackAddress));