Hi Nick,
Please see the comments in line in the mediator code;
---
Code Using injectMessage
------------------------
public boolean mediate(MessageContext ctx) {
final SynapseEnvironment env = ctx.getEnvironment();
final MessageContext newCtx = env.createMessageContext();
I think the above line is where you are doing something wrong, because it
seems that your newCtx does not have a Axis2 ConfigurationContext associated
with it.
Use the following method to get the newCtx instead and try,
final MessageContext newCtx = new Axis2MessageContext(((Axis2MessageContext)
ctx).getAxis2MessageContext(), ctx.getConfiguration(), env);
Just give it a try and let me know if there are any issues.
final SOAPFactory soapFac =
OMAbstractFactory.getSOAP12Factory();
final OMFactory omFac = OMAbstractFactory.getOMFactory();
final SOAPEnvelope msg = soapFac.getDefaultEnvelope();
final SOAPHeader hdr = msgOne.getHeader();
final OMNamespace nrexNs
= omFac.createOMNamespace("http://www.cs.ncl.ac.uk/
nrex/", "nrex");
final OMElement nrexHdr
= omFac.createOMElement("ProtocolHeader", nrexNs);
nrexHdr.addAttribute("msgNum", "1", nrexNs);
hdr.addChild(nrexHdr);
msg.getBody().addChild(nrexHdr);
try {
newCtx.setEnvelope(msg);
} catch (AxisFault e) {
e.printStackTrace();
return false;
}
newCtx.setTo(
new EndpointReference("http://localhost:8080/nrex/
process/"));
newCtx.setWSAAction("urn:testing");
env.injectMessage(newCtx);
return true;
}
Thanks,
Ruwan.
--
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"