You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jejmaster <je...@gmail.com> on 2010/03/29 11:42:09 UTC

Convert CXFRS XML Response To HL7 Format

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 this message in context: http://old.nabble.com/Convert-CXFRS-XML-Response-To-HL7-Format-tp28066971p28066971.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Convert CXFRS XML Response To HL7 Format

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Its just a lot to explain about data transformation.
I would suggest to read chapter 3 in the Camel in action book which
covers this concept in 30+ pages.



On Mon, Mar 29, 2010 at 11:42 AM, jejmaster <je...@gmail.com> 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 this message in context: http://old.nabble.com/Convert-CXFRS-XML-Response-To-HL7-Format-tp28066971p28066971.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Convert CXFRS XML Response To HL7 Format

Posted by Willem Jiang <wi...@gmail.com>.
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.

[1]https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsInvoker.java
[2]https://issues.apache.org/activemq/browse/CAMEL-2602
[3]http://svn.apache.org/viewvc?rev=929004&view=rev


Willem

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!