Sunday, September 19, 2010

How to get/set properties from/to JBI NMR within cxf se endpoint

As the typical way to use cxf se component in Apache Servicemix[1] or FuseSource[2] ESB is like
JBI consumer endpoint<=====> cxf se endpoint.Sometimes customer want to put extra properties during runtime in JBI NormalizedMessage with JBI consumer endpoint and retrieve it from cxf se endpoint later on.
With SMXCOMP-593[3], we provide a webservice friendly and CXF-ish way to retrieve and set properties in cxf se endpoint.
Customer just need add code like

    @Resource
    private WebServiceContext wsContext;
to inject WebServiceContext to this CxfSeEndpoint

and use
    javax.xml.ws.handler.MessageContext ctx = wsContext.getMessageContext();
    org.apache.cxf.message.Message message = ((org.apache.cxf.jaxws.context.WrappedMessageContext) ctx).getWrappedMessage();
    String propertyValue = (String) message.get("PROPERTY_NAME");//retrieve property
    message.put("PROPERTY_NAME", "newPropertyValue");//set property

to get/set properties within cxf se endpoint.

[1]http://servicemix.apache.org/home.html
[2]http://fusesource.com/
[3]https://issues.apache.org/activemq/browse/SMXCOMP-593

2 comments:

  1. Wow what a nice post. I am impressed from it.

    Thanks for more sharing........



    zvnproperties

    ReplyDelete
  2. Hi Fang,

    Do you have any sample Fuse project to demo the integration of hibernate with rest service .

    If you have can you please share the link

    ReplyDelete