Hi Remsy
If you want to manage soap headers at the axis2 server end (before
response from the service is return back to synapse), then best practice
is writing axis2 handlers [1] [2].
If you want to manage the headers in the ESB level, then best practice
is using header mediator. Currently, it supports only text values for
headers. If you want to add xml fragment as headers it is better to
extend header mediator so that it can be reused. Even in your custom
mediator, if you want to do standard ESB functionality (add/remove
(headers, properties)/send/create fault, etc), its better to try to use
pre-defines sequences (As mediators such as throttle, cache, etc do --
take look at configuration for those and implementation too). My advice
is, simply, try to include only your main concern for a mediator in the
custom code and reuse standard ESB behavior using existing mediators
even you may need some improvements on the existing mediators. This
improves existing stable mediators; your mediator's responsibility will
be clear and it also makes your mediator to be a reusable component as
it does a particular responsibility - one concern.
Thanks
Indika
[1] http://www.developer.com/java/web/article.php/10935_3529321_1
[2] http://ws.apache.org/axis2/1_4_1/modules.html
[1] http://www.developer.com/java/web/article.php/10935_3529321_1
[2] http://ws.apache.org/axis2/1_4_1/modules.html
Schmilinsky, Remsy wrote:
Hi, can you indicate how to add a custom soap header to an axis2 MessageContext
object ? I have this web service called by esb:
public OMElement getRspAttachment(OMElement request) throws Exception {
MessageContext inMessageContext = MessageContext.getCurrentMessageContext();
OperationContext operationContext = inMessageContext.getOperationContext();
DataSource rspDataSource = new ByteArrayDataSource(("<?xml version=\"1.0\" encoding=\"UTF-8\"?><response>" + "a response..." + "</response>").getBytes(), "text/xml; charset=UTF-8");
MessageContext outMessageContext =
operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
outMessageContext.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_SWA,
org.apache.axis2.Constants.VALUE_TRUE);
DataHandler rspDataHandler = new DataHandler(rspDataSource);
OMFactory factory = request.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples/xsd", "m0");
OMElement payload = factory.createOMElement("transformResponse", ns);
OMElement msgId = factory.createOMElement("xmlMsgId", ns);
OMElement response = factory.createOMElement("response", ns);
String xmlRspID = outMessageContext.addAttachment(rspDataHandler);
msgId.setText(xmlRspID);
response.addChild(msgId);
payload.addChild(response);
return payload;
}
the resulting attachment will then be processed by esb, but I need to add some
values in the header.
thanks
_______________________________________________
Esb-java-user mailing list
[email protected]
http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-user
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.173 / Virus Database: 270.8.1/1727 - Release Date: 10/15/2008 8:02 PM
_______________________________________________
Esb-java-user mailing list
[email protected]
http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-user