Hi,
You have two ways to do it:
- the EIP one. Using Camel, you can setup a content enricher. With the
content enricher, you can add data to the message in transit.
It looks like:
from("jbi:A").setBody(body().append("<appid>12</appid>")).to("jbi:B");
You can find more information here:
http://camel.apache.org/content-enricher.html
- the other way is to use the programmatic one. Using the
servicemix-bean you can deploy a bean that get the message content and
apply the transformation that you need.
For example, you have a HTTP endpoint define like this:
<http:soap-consumer service="test:my" endpoint="soap"
targetService="test:my" targetEndpoint="bean"
locationURI="http://0.0.0.0:8192/test"/>
You can see that it routes to a bean endpoint defined like this:
<bean:endpoint service="test:my" endpoint="bean" bean="#listenerBean"/>
<bean id="listenerBean" class="org.apache.servicemix.bean.ListenerBean"/>
The ListenerBean looks like this:
import org.apache.servicemix.jbi.listener.MessageExchangeListener;
import org.apache.servicemix.jbi.util.MessageUtil;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import javax.annotation.Resource;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.transform.Source;
public class ListenerBean implements MessageExchangeListener {
@Resource
private DeliveryChannel channel;
public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
NormalizedMessage message =
exchange.getMessage("in");
Source content = message.getContent();
String body = (new
SourceTransformer()).toString(content);
body = body + "<appid>test</appid>";
message.setContent(content);
exchange.setMessage(message, "out");
channel.send(exchange);
}
}
}
Like this ServiceMix can embed transformation logic or BAM.
Regards
JB
roshansn wrote:
Hi,
I need to pass some information like application id in additional to the
soap body. How I can configure this. When request comes for a web service i
need to get the that additional information from a service engine.
Thanks