You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by mario_horny <ma...@dzbank.de> on 2008/11/12 11:22:41 UTC

getting the in message in a custom processor with dataFormat=PAYLOAD

Hi all,

I have a custom processor that needs to transform a cxf message before it is
routed to the destination endpoint. The code of the process() method looks
like that:

public void process( Exchange e ) {

Message iMsg = e.getIn();

msgStr = iMsg.getBody(String.class).toString();

System.out.println("Received msg=" + msgStr );

// do the transformation ....
String transStr = doTransform( msgStr );

Message oMsg = e.getOut();

oMsg.setBody( transStr);

}

This works pretty fine, if the dataFormat is POJO or MESSAGE. In these
cases, the Java parameter (POJO) or the whole xml message (MESSAGE) are
printed out by the println(...) . If the dataFormat is PAYLOAD, only the
class reference ValidatingStreamReader@xyz is printed out.

I could find no way to get the payload data as a string. I read that I need
to write an own converter to get the data, but at the end of the day my
problem is that I could find no way to get the data in any format (I'm not
fixed to use a string object). 
I tried to get the body as a Map, InputStream, Collection,
MessageContentsList... but non of these classes worked. I found out that
some the classes work for some dataFormats (InputStream works fine for
MESSAGE, MessageContentsList works fine for POJO), but nothing worked out
for PAYLOAD. 

Does anybody have an example how to access the message body for
dataFormat=PAYLOAD ? Is there a common way to access the body for all
dataFormats ? 

Many thanks in advance,
Mario
-- 
View this message in context: http://www.nabble.com/getting-the-in-message-in-a-custom-processor-with-dataFormat%3DPAYLOAD-tp20457607s22882p20457607.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: getting the in message in a custom processor with dataFormat=PAYLOAD

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

The message of PAYLOAD dataFormat will take out soap envelope and put
the payload message into the message.
You can use List<Element> partList = iMsg.getBody(List.class) to get the
payload message and Element header = iMsg.getBody(Element.class) to get
the soap header.

Willem

mario_horny wrote:
> Hi all,
> 
> I have a custom processor that needs to transform a cxf message before it is
> routed to the destination endpoint. The code of the process() method looks
> like that:
> 
> public void process( Exchange e ) {
> 
> Message iMsg = e.getIn();
> 
> msgStr = iMsg.getBody(String.class).toString();
> 
> System.out.println("Received msg=" + msgStr );
> 
> // do the transformation ....
> String transStr = doTransform( msgStr );
> 
> Message oMsg = e.getOut();
> 
> oMsg.setBody( transStr);
> 
> }
> 
> This works pretty fine, if the dataFormat is POJO or MESSAGE. In these
> cases, the Java parameter (POJO) or the whole xml message (MESSAGE) are
> printed out by the println(...) . If the dataFormat is PAYLOAD, only the
> class reference ValidatingStreamReader@xyz is printed out.
> 
> I could find no way to get the payload data as a string. I read that I need
> to write an own converter to get the data, but at the end of the day my
> problem is that I could find no way to get the data in any format (I'm not
> fixed to use a string object). 
> I tried to get the body as a Map, InputStream, Collection,
> MessageContentsList... but non of these classes worked. I found out that
> some the classes work for some dataFormats (InputStream works fine for
> MESSAGE, MessageContentsList works fine for POJO), but nothing worked out
> for PAYLOAD. 
> 
> Does anybody have an example how to access the message body for
> dataFormat=PAYLOAD ? Is there a common way to access the body for all
> dataFormats ? 
> 
> Many thanks in advance,
> Mario


Re: getting the in message in a custom processor with dataFormat=PAYLOAD

Posted by mario_horny <ma...@dzbank.de>.
Hi Willem,

works !!
Mario


mario_horny wrote:
> 
> Hi all,
> 
> I have a custom processor that needs to transform a cxf message before it
> is routed to the destination endpoint. The code of the process() method
> looks like that:
> 
> public void process( Exchange e ) {
> 
> Message iMsg = e.getIn();
> 
> msgStr = iMsg.getBody(String.class).toString();
> 
> System.out.println("Received msg=" + msgStr );
> 
> // do the transformation ....
> String transStr = doTransform( msgStr );
> 
> Message oMsg = e.getOut();
> 
> oMsg.setBody( transStr);
> 
> }
> 
> This works pretty fine, if the dataFormat is POJO or MESSAGE (defined in
> the RouteBuilder). In these cases, the Java parameter (POJO) or the whole
> xml message (MESSAGE) are printed out by the println(...) . If the
> dataFormat is PAYLOAD, only the class reference ValidatingStreamReader@xyz
> is printed out.
> 
> I could find no way to get the payload data as a string. I read that I
> need to write an own converter to get the data, but at the end of the day
> my problem is that I could find no way to get the data in any format (I'm
> not fixed to use a string object). 
> I tried to get the body as a Map, InputStream, Collection,
> MessageContentsList... but non of these classes worked. I found out that
> some the classes work for some dataFormats (InputStream works fine for
> MESSAGE, MessageContentsList works fine for POJO), but nothing worked out
> for PAYLOAD. 
> 
> Does anybody have an example how to access the message body for
> dataFormat=PAYLOAD ? Is there a common way to access the body for all
> dataFormats ? 
> 
> Many thanks in advance,
> Mario
> 

-- 
View this message in context: http://www.nabble.com/getting-the-in-message-in-a-custom-processor-with-dataFormat%3DPAYLOAD-tp20457607s22882p20503343.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: getting the in message in a custom processor with dataFormat=PAYLOAD

Posted by Willem Jiang <wi...@gmail.com>.
Hi Mario,

I just fixed the SOAP header bug CAMEL-1088[1] last week. You should get
the SOAP header by using Camel 1.5.1-snapshot.
Here is an example of it in the CXF wiki page[2].

For the SOAP message, you could use the Provider[3] API to get the
SOAPMessage in your processor, by checking the SOAPMessage object's type
class , I think it is easy to determine the SOAP protocol version.

[1] https://issues.apache.org/activemq/browse/CAMEL-1088
[2]
http://activemq.apache.org/camel/cxf.html#CXF-HowtodealwiththemessageforthecamelcxfendpointinPAYLOADdataformat
[3]
http://activemq.apache.org/camel/cxf-example.html#CXFExample-CXFexampleforusingtheWebServiceProviderAPI

Willem


mario_horny wrote:
> Hi again,
> 
> the snipped given by Willem works fine!
> 
> But this brings me to another question. How can I determine, which
> dataFormat is used to send the data ? My first thought was to check out the
> message header attribute "QUERY_STRING". But since this is empty, I've got
> no idea. Anyone out there with a hint ?
> 
> Another question I'm currently facing in this conjunction is, how to
> determine the SOAP protocol version (1.1 or 1.2) in the process() method.
> Again, any help is welcome.
> 
> Greets,
> Mario
>  
> 
> mario_horny wrote:
>> Hi all,
>>
>> I have a custom processor that needs to transform a cxf message before it
>> is routed to the destination endpoint. The code of the process() method
>> looks like that:
>>
>> public void process( Exchange e ) {
>>
>> Message iMsg = e.getIn();
>>
>> msgStr = iMsg.getBody(String.class).toString();
>>
>> System.out.println("Received msg=" + msgStr );
>>
>> // do the transformation ....
>> String transStr = doTransform( msgStr );
>>
>> Message oMsg = e.getOut();
>>
>> oMsg.setBody( transStr);
>>
>> }
>>
>> This works pretty fine, if the dataFormat is POJO or MESSAGE (defined in
>> the RouteBuilder). In these cases, the Java parameter (POJO) or the whole
>> xml message (MESSAGE) are printed out by the println(...) . If the
>> dataFormat is PAYLOAD, only the class reference ValidatingStreamReader@xyz
>> is printed out.
>>
>> I could find no way to get the payload data as a string. I read that I
>> need to write an own converter to get the data, but at the end of the day
>> my problem is that I could find no way to get the data in any format (I'm
>> not fixed to use a string object). 
>> I tried to get the body as a Map, InputStream, Collection,
>> MessageContentsList... but non of these classes worked. I found out that
>> some the classes work for some dataFormats (InputStream works fine for
>> MESSAGE, MessageContentsList works fine for POJO), but nothing worked out
>> for PAYLOAD. 
>>
>> Does anybody have an example how to access the message body for
>> dataFormat=PAYLOAD ? Is there a common way to access the body for all
>> dataFormats ? 
>>
>> Many thanks in advance,
>> Mario
>>
> 


Re: getting the in message in a custom processor with dataFormat=PAYLOAD

Posted by mario_horny <ma...@dzbank.de>.
Hi again,

the snipped given by Willem works fine!

But this brings me to another question. How can I determine, which
dataFormat is used to send the data ? My first thought was to check out the
message header attribute "QUERY_STRING". But since this is empty, I've got
no idea. Anyone out there with a hint ?

Another question I'm currently facing in this conjunction is, how to
determine the SOAP protocol version (1.1 or 1.2) in the process() method.
Again, any help is welcome.

Greets,
Mario
 

mario_horny wrote:
> 
> Hi all,
> 
> I have a custom processor that needs to transform a cxf message before it
> is routed to the destination endpoint. The code of the process() method
> looks like that:
> 
> public void process( Exchange e ) {
> 
> Message iMsg = e.getIn();
> 
> msgStr = iMsg.getBody(String.class).toString();
> 
> System.out.println("Received msg=" + msgStr );
> 
> // do the transformation ....
> String transStr = doTransform( msgStr );
> 
> Message oMsg = e.getOut();
> 
> oMsg.setBody( transStr);
> 
> }
> 
> This works pretty fine, if the dataFormat is POJO or MESSAGE (defined in
> the RouteBuilder). In these cases, the Java parameter (POJO) or the whole
> xml message (MESSAGE) are printed out by the println(...) . If the
> dataFormat is PAYLOAD, only the class reference ValidatingStreamReader@xyz
> is printed out.
> 
> I could find no way to get the payload data as a string. I read that I
> need to write an own converter to get the data, but at the end of the day
> my problem is that I could find no way to get the data in any format (I'm
> not fixed to use a string object). 
> I tried to get the body as a Map, InputStream, Collection,
> MessageContentsList... but non of these classes worked. I found out that
> some the classes work for some dataFormats (InputStream works fine for
> MESSAGE, MessageContentsList works fine for POJO), but nothing worked out
> for PAYLOAD. 
> 
> Does anybody have an example how to access the message body for
> dataFormat=PAYLOAD ? Is there a common way to access the body for all
> dataFormats ? 
> 
> Many thanks in advance,
> Mario
> 

-- 
View this message in context: http://www.nabble.com/getting-the-in-message-in-a-custom-processor-with-dataFormat%3DPAYLOAD-tp20457607s22882p20617265.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: getting the in message in a custom processor with dataFormat=PAYLOAD

Posted by Willem Jiang <wi...@gmail.com>.
Oh, It's my fault, you can get the List from the Camel message.
You need to get the CXF message from the Camel message, and  get the
List Object from CXF message.

Here is the code snippet

return new RouteBuilder() {
            public void configure() {
                // START SNIPPET: payload
                from(routerEndpointURI).process(new Processor() {
                    public void process(Exchange exchange) throws
Exception {
                        Message inMessage = exchange.getIn();
                        if(inMessage instanceof CxfMessage) {
                            CxfMessage message = (CxfMessage) inMessage;
                            List<Element> elements =
message.getMessage().get(List.class);
                            assertNotNull("We should get the elements
here" , elements);
                            assertEquals("Get the wrong elements size" ,
elements.size(), 1);
                            assertEquals("Get the wrong namespace URI" ,
elements.get(0).getNamespaceURI(),
"http://cxf.component.camel.apache.org/");
                        }
                    }

                })
                .to(serviceEndpointURI);
                // END SNIPPET: payload
            }

Willem

mario_horny wrote:
> Hi,
> 
> does not work too.
> 
> the code snippet
> 
> public void process( Exchange anEx )  {
> 		
> Message iMsg = anEx.getIn();
> List<Element> myList =  (List<Element>) iMsg.getBody(List.class);
> System.out.println("got list=" + myList);
> ....
> }
> 
> leads to a stack trace, since myList is null. Here is the output:
> 
> [java] Router ready ... 
>      [java] Nov 12, 2008 3:01:07 PM
> org.apache.camel.component.cxf.interceptors.AbstractMessageInInterceptor
> createDOMMessage
>      [java] INFO: AbstractMessageInInterceptor Converting Stax Stream to DOM
>      [java] Nov 12, 2008 3:01:07 PM
> org.apache.camel.component.cxf.interceptors.AbstractMessageInInterceptor
> handleMessage
>      [java] INFO: AbstractRoutingMessageInInterceptor Infer
> BindingOperationInfo.
>      [java] Nov 12, 2008 3:01:07 PM
> org.apache.camel.component.cxf.interceptors.AbstractMessageInInterceptor
> handleMessage
>      [java] INFO: DOMInInterceptor- BindingOperation
> is:{http://apache.org/hello_world_soap_http}greetMe
>      [java] Start process ...
>      [java] got list=null
>      [java] Start process ...
>      [java] got list=null
>      [java] Start process ...
>      [java] got list=null
>      [java] Start process ...
>      [java] got list=null
>      [java] Start process ...
>      [java] got list=null
>      [java] Start process ...
>      [java] got list=null
>      [java] Nov 12, 2008 3:01:13 PM
> org.apache.camel.component.cxf.interceptors.SoapMessageOutInterceptor
> handleMessage
>      [java] INFO: SoapMessageOutInterceptor binding operation style
> processing.
>      [java] Nov 12, 2008 3:01:13 PM
> org.apache.cxf.phase.PhaseInterceptorChain doIntercept
>      [java] INFO: Interceptor has thrown exception, unwinding now
>      [java] java.lang.NullPointerException
>      [java] 	at
> org.apache.camel.component.cxf.interceptors.PayloadContentRedirectInterceptor.handleMessage(PayloadContentRedirectInterceptor.java:53)
>      [java] 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
>      [java] 	at
> org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74)
>      [java] 	at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
>      [java] 	at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:77)
>      [java] 	at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:280)
>      [java] 	at
> org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:254)
>      [java] 	at
> org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
>      [java] 	at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
>      [java] 	at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
>      [java] 	at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>      [java] 	at org.mortbay.jetty.Server.handle(Server.java:324)
>      [java] 	at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
>      [java] 	at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
>      [java] 	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
>      [java] 	at
> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>      [java] 	at
> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
>      [java] 	at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
>      [java] 	at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
>      [java] Nov 12, 2008 3:01:13 PM
> org.apache.camel.component.cxf.interceptors.FaultOutInterceptor
> handleMessage
>      [java] INFO: FaultOutInterceptor Creating SoapFault
> 
> The configuration of the cxf endpoint in the router is (accoring to the
> greeter example):
> 
> private static final String HELLOWORLD_SERVICE_QUERY =
> "?serviceClass=org.apache.hello_world_soap_http.Greeter&dataFormat=PAYLOAD";
> private static String FROM_ENDPOINT_LOCATION =
> "http://localhost:13012/helloworldrouter";
> private static String TO_ENDPOINT_LOCATION =
> "http://localhost:50000/helloworldserver";
> 	
> public void configure() throws Exception {
> 		
> MercatorProcessor p = new MercatorProcessor();
> 		
> System.out.println("Mercator Processor succesfully instantiated ...");
> 		
> this.from( getFromEndpointURI() ).process( p ).to( getToEndpointURI() );
> 		
> System.out.println("Route succesfully configured ...");
> }
> 	
> 	
> private String getFromEndpointURI() {
> 		
> return "cxf://" + FROM_ENDPOINT_LOCATION + HELLOWORLD_SERVICE_QUERY ;
> }
> Any idea ?
> 
> Mario
> 
> 
> 
> 
> 
> 
> 
> 
> mario_horny wrote:
>> Hi all,
>>
>> I have a custom processor that needs to transform a cxf message before it
>> is routed to the destination endpoint. The code of the process() method
>> looks like that:
>>
>> public void process( Exchange e ) {
>>
>> Message iMsg = e.getIn();
>>
>> msgStr = iMsg.getBody(String.class).toString();
>>
>> System.out.println("Received msg=" + msgStr );
>>
>> // do the transformation ....
>> String transStr = doTransform( msgStr );
>>
>> Message oMsg = e.getOut();
>>
>> oMsg.setBody( transStr);
>>
>> }
>>
>> This works pretty fine, if the dataFormat is POJO or MESSAGE (defined in
>> the RouteBuilder). In these cases, the Java parameter (POJO) or the whole
>> xml message (MESSAGE) are printed out by the println(...) . If the
>> dataFormat is PAYLOAD, only the class reference ValidatingStreamReader@xyz
>> is printed out.
>>
>> I could find no way to get the payload data as a string. I read that I
>> need to write an own converter to get the data, but at the end of the day
>> my problem is that I could find no way to get the data in any format (I'm
>> not fixed to use a string object). 
>> I tried to get the body as a Map, InputStream, Collection,
>> MessageContentsList... but non of these classes worked. I found out that
>> some the classes work for some dataFormats (InputStream works fine for
>> MESSAGE, MessageContentsList works fine for POJO), but nothing worked out
>> for PAYLOAD. 
>>
>> Does anybody have an example how to access the message body for
>> dataFormat=PAYLOAD ? Is there a common way to access the body for all
>> dataFormats ? 
>>
>> Many thanks in advance,
>> Mario
>>
> 


Re: getting the in message in a custom processor with dataFormat=PAYLOAD

Posted by mario_horny <ma...@dzbank.de>.
Hi,

does not work too.

the code snippet

public void process( Exchange anEx )  {
		
Message iMsg = anEx.getIn();
List<Element> myList =  (List<Element>) iMsg.getBody(List.class);
System.out.println("got list=" + myList);
....
}

leads to a stack trace, since myList is null. Here is the output:

[java] Router ready ... 
     [java] Nov 12, 2008 3:01:07 PM
org.apache.camel.component.cxf.interceptors.AbstractMessageInInterceptor
createDOMMessage
     [java] INFO: AbstractMessageInInterceptor Converting Stax Stream to DOM
     [java] Nov 12, 2008 3:01:07 PM
org.apache.camel.component.cxf.interceptors.AbstractMessageInInterceptor
handleMessage
     [java] INFO: AbstractRoutingMessageInInterceptor Infer
BindingOperationInfo.
     [java] Nov 12, 2008 3:01:07 PM
org.apache.camel.component.cxf.interceptors.AbstractMessageInInterceptor
handleMessage
     [java] INFO: DOMInInterceptor- BindingOperation
is:{http://apache.org/hello_world_soap_http}greetMe
     [java] Start process ...
     [java] got list=null
     [java] Start process ...
     [java] got list=null
     [java] Start process ...
     [java] got list=null
     [java] Start process ...
     [java] got list=null
     [java] Start process ...
     [java] got list=null
     [java] Start process ...
     [java] got list=null
     [java] Nov 12, 2008 3:01:13 PM
org.apache.camel.component.cxf.interceptors.SoapMessageOutInterceptor
handleMessage
     [java] INFO: SoapMessageOutInterceptor binding operation style
processing.
     [java] Nov 12, 2008 3:01:13 PM
org.apache.cxf.phase.PhaseInterceptorChain doIntercept
     [java] INFO: Interceptor has thrown exception, unwinding now
     [java] java.lang.NullPointerException
     [java] 	at
org.apache.camel.component.cxf.interceptors.PayloadContentRedirectInterceptor.handleMessage(PayloadContentRedirectInterceptor.java:53)
     [java] 	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
     [java] 	at
org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:74)
     [java] 	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
     [java] 	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:77)
     [java] 	at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:280)
     [java] 	at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:254)
     [java] 	at
org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
     [java] 	at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
     [java] 	at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
     [java] 	at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
     [java] 	at org.mortbay.jetty.Server.handle(Server.java:324)
     [java] 	at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
     [java] 	at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
     [java] 	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
     [java] 	at
org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
     [java] 	at
org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
     [java] 	at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
     [java] 	at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
     [java] Nov 12, 2008 3:01:13 PM
org.apache.camel.component.cxf.interceptors.FaultOutInterceptor
handleMessage
     [java] INFO: FaultOutInterceptor Creating SoapFault

The configuration of the cxf endpoint in the router is (accoring to the
greeter example):

private static final String HELLOWORLD_SERVICE_QUERY =
"?serviceClass=org.apache.hello_world_soap_http.Greeter&dataFormat=PAYLOAD";
private static String FROM_ENDPOINT_LOCATION =
"http://localhost:13012/helloworldrouter";
private static String TO_ENDPOINT_LOCATION =
"http://localhost:50000/helloworldserver";
	
public void configure() throws Exception {
		
MercatorProcessor p = new MercatorProcessor();
		
System.out.println("Mercator Processor succesfully instantiated ...");
		
this.from( getFromEndpointURI() ).process( p ).to( getToEndpointURI() );
		
System.out.println("Route succesfully configured ...");
}
	
	
private String getFromEndpointURI() {
		
return "cxf://" + FROM_ENDPOINT_LOCATION + HELLOWORLD_SERVICE_QUERY ;
}
Any idea ?

Mario








mario_horny wrote:
> 
> Hi all,
> 
> I have a custom processor that needs to transform a cxf message before it
> is routed to the destination endpoint. The code of the process() method
> looks like that:
> 
> public void process( Exchange e ) {
> 
> Message iMsg = e.getIn();
> 
> msgStr = iMsg.getBody(String.class).toString();
> 
> System.out.println("Received msg=" + msgStr );
> 
> // do the transformation ....
> String transStr = doTransform( msgStr );
> 
> Message oMsg = e.getOut();
> 
> oMsg.setBody( transStr);
> 
> }
> 
> This works pretty fine, if the dataFormat is POJO or MESSAGE (defined in
> the RouteBuilder). In these cases, the Java parameter (POJO) or the whole
> xml message (MESSAGE) are printed out by the println(...) . If the
> dataFormat is PAYLOAD, only the class reference ValidatingStreamReader@xyz
> is printed out.
> 
> I could find no way to get the payload data as a string. I read that I
> need to write an own converter to get the data, but at the end of the day
> my problem is that I could find no way to get the data in any format (I'm
> not fixed to use a string object). 
> I tried to get the body as a Map, InputStream, Collection,
> MessageContentsList... but non of these classes worked. I found out that
> some the classes work for some dataFormats (InputStream works fine for
> MESSAGE, MessageContentsList works fine for POJO), but nothing worked out
> for PAYLOAD. 
> 
> Does anybody have an example how to access the message body for
> dataFormat=PAYLOAD ? Is there a common way to access the body for all
> dataFormats ? 
> 
> Many thanks in advance,
> Mario
> 

-- 
View this message in context: http://www.nabble.com/getting-the-in-message-in-a-custom-processor-with-dataFormat%3DPAYLOAD-tp20457607s22882p20461139.html
Sent from the Camel - Users mailing list archive at Nabble.com.