camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <>
Subject Re: Convert CXFRS XML Response To HL7 Format
Date Tue, 30 Mar 2010 06:15:50 GMT
If you take a look of CxfRsInvoker[1], you will find the how CXFRS store 
the request message into the message body.
Basically the REST request will be turned into a method invocation in 
the CxfRsInvoker, and we put the method method into the inMessage 
header, and the parameters into the inMessage body as a Object array.
Current camel-cxf module doesn't support the get the parameter object 
with the Message.getBody(Type.class), you have to writing some customer 
code to go through the Object array to look for the right object.

So I committed a quick enhancement[1] of getting the request object from 
the message body[2], so if you want to get the request message object, 
you can try out the latest Camel 2.3.0-SNAPSHOT.



jejmaster wrote:
> Hi,
> I would like to inquire regarding converting a CXFRS XML Response to HL7
> Format. Currently I have this cxfrs route:
> <cxf:rsServer id="restRouter" address="/restRouter/"
> serviceClass="com.project.service.impl.ServiceManagerImpl" />
> <cxf:rsClient id="restEndpoint"
> address="http://localhost:8080/services/rest"
> serviceClass="com.project.service.impl.ServiceManagerImpl" />
> <route>
>      <from uri="cxfrs:bean:restRouter"/>
>       <process ref="hl7Processor"/>
>      <to uri="cxfrs:bean:restEndpoint"/>
> </route> 
> <bean id="hl7Processor" class="com.slmc.camel.processor.HL7Processor"/>
> What I am trying to do is to process the Exchange and getting the in message
> object then setting the out message with my parsed HL7 String.
> Here's my implementation of the HL7Processor:
> public class HL7Processor implements Processor {
>     private static Logger logger = Logger.getLogger(HL7Processor.class);
>     @Override
>     public void process(Exchange exchange) throws Exception {
>         logger.debug("entering `process` method...");
>         PatientTO patientTo = exchange.getIn().getBody(PatientTO.class);
>         String hl7XML = convertToHL7(patientTo);
>         exchange.getOut().setBody(hl7XML, String.class);
>     }
> }
> The current effect is that I am getting null on patientTO. Here are my
> questions:
> 1. During the exchange of two cxfrs endpoints, what should be the type of
> exchange.getIn().getBody(..)?
> 2. Is this the correct solution for my goal? 
> Thanks in advance!

View raw message