private ComponentContext context;
public String greetMe(String me) {
try {
// here use client api to test the injected context to invoke another endpoint
ServiceMixClient client = new ServiceMixClientFacade(this.context);
InOut exchange = client.createInOutExchange();
NormalizedMessage message = exchange.getInMessage();
message.setContent(new StringSource(
"<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+ " <part>"
+ " <add xmlns='http://apache.org/cxf/calculator/types'>"
+ " <arg0>1</arg0>"
+ " <arg1>2</arg1>"
+ " </add>"
+ " </part>"
+ "</message>"));
exchange.setService(new QName("http://apache.org/cxf/calculator", "CalculatorService"));
exchange.setInterfaceName(new QName("http://apache.org/cxf/calculator", "CalculatorPortType"));
exchange.setOperation(new QName("http://apache.org/cxf/calculator", "add"));
client.sendSync(exchange);
} catch (JBIException e) {
//
}
return "Hello " + me + " " + context.getComponentName();