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 2009/03/27 16:35:25 UTC

PAYLOAD access API changed with camel from camel 1.3.x.x => 1.5.1.1 ?

Hi guys,

I'm using camel 1.5.1.1 coming with artix 5.5. 

I was trying to get back to a code snipped that Willem has provided to me a
couple of months ago (back when I was still using artix 5.1 with camel
1.3.x.x) that showed how to access a message in PAYLOAD mode:

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); 
....
}

But it seems that the API has changed in the meanwhile since the
getMessage() method on CxfMessage class seems to no longer exist. What's the
API for 1.5.1.1 to access the message ?

Best regards,
Mario
-- 
View this message in context: http://www.nabble.com/PAYLOAD-access-API-changed-with-camel-from-camel-1.3.x.x-%3D%3E-1.5.1.1---tp22744147p22744147.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: PAYLOAD access API changed with camel from camel 1.3.x.x => 1.5.1.1 ?

Posted by mario_horny <ma...@dzbank.de>.
Sorry to have wasted your time, guys. The API IS still there and works as
described. Was just a wrong configuration of my eclipse environment :-( !

Best regards,
Mario




William Tam wrote:
> 
> That's strange.  The APIs didn't change (looking at camel-1.5.1-fuse)
> .  The getMessage() method is still there.
> 
> On Fri, Mar 27, 2009 at 11:35 AM, mario_horny <ma...@dzbank.de>
> wrote:
>>
>> Hi guys,
>>
>> I'm using camel 1.5.1.1 coming with artix 5.5.
>>
>> I was trying to get back to a code snipped that Willem has provided to me
>> a
>> couple of months ago (back when I was still using artix 5.1 with camel
>> 1.3.x.x) that showed how to access a message in PAYLOAD mode:
>>
>> 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);
>> ....
>> }
>>
>> But it seems that the API has changed in the meanwhile since the
>> getMessage() method on CxfMessage class seems to no longer exist. What's
>> the
>> API for 1.5.1.1 to access the message ?
>>
>> Best regards,
>> Mario
>> --
>> View this message in context:
>> http://www.nabble.com/PAYLOAD-access-API-changed-with-camel-from-camel-1.3.x.x-%3D%3E-1.5.1.1---tp22744147p22744147.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/PAYLOAD-access-API-changed-with-camel-from-camel-1.3.x.x-%3D%3E-1.5.1.1---tp22744147p22745103.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: PAYLOAD access API changed with camel from camel 1.3.x.x => 1.5.1.1 ?

Posted by William Tam <em...@gmail.com>.
That's strange.  The APIs didn't change (looking at camel-1.5.1-fuse)
.  The getMessage() method is still there.

On Fri, Mar 27, 2009 at 11:35 AM, mario_horny <ma...@dzbank.de> wrote:
>
> Hi guys,
>
> I'm using camel 1.5.1.1 coming with artix 5.5.
>
> I was trying to get back to a code snipped that Willem has provided to me a
> couple of months ago (back when I was still using artix 5.1 with camel
> 1.3.x.x) that showed how to access a message in PAYLOAD mode:
>
> 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);
> ....
> }
>
> But it seems that the API has changed in the meanwhile since the
> getMessage() method on CxfMessage class seems to no longer exist. What's the
> API for 1.5.1.1 to access the message ?
>
> Best regards,
> Mario
> --
> View this message in context: http://www.nabble.com/PAYLOAD-access-API-changed-with-camel-from-camel-1.3.x.x-%3D%3E-1.5.1.1---tp22744147p22744147.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: PAYLOAD access API changed with camel from camel 1.3.x.x => 1.5.1.1 ?

Posted by Willem Jiang <wi...@gmail.com>.
I just check the test code in Camel 1.x branch

 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/");
 }


So I think the old Camel 1.3.x code should work in Camel fuse 1.5.1

But for Camel 2.0 the code changed like this

CxfPayload<?> payload = exchange.getIn().getBody(CxfPayload.class);
List<Element> elements = payload.getBody();
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/");


Willem


mario_horny wrote:
> Hi guys,
> 
> I'm using camel 1.5.1.1 coming with artix 5.5. 
> 
> I was trying to get back to a code snipped that Willem has provided to me a
> couple of months ago (back when I was still using artix 5.1 with camel
> 1.3.x.x) that showed how to access a message in PAYLOAD mode:
> 
> 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); 
> ....
> }
> 
> But it seems that the API has changed in the meanwhile since the
> getMessage() method on CxfMessage class seems to no longer exist. What's the
> API for 1.5.1.1 to access the message ?
> 
> Best regards,
> Mario


Re: PAYLOAD access API changed with camel from camel 1.3.x.x => 1.5.1.1 ?

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

I already tried

List<Element> elements = exchange.getIn().getBody(List.class);

before I opend the request. But this throws an exception that tells me that
there is no converter from CxfMessage => List available. 

Trying out

Object body = exchange.getIn().getBody(); 

tells me that body's class is com.ctc.wstx.sr.ValidatingStreamReader. To be
honest, I've got no idea how to deal with this class.

Is there a chance to forward the request to Willem ?

Best regards,
Mario




Claus Ibsen-2 wrote:
> 
> On Fri, Mar 27, 2009 at 4:35 PM, mario_horny <ma...@dzbank.de>
> wrote:
>>
>> Hi guys,
>>
>> I'm using camel 1.5.1.1 coming with artix 5.5.
>>
>> I was trying to get back to a code snipped that Willem has provided to me
>> a
>> couple of months ago (back when I was still using artix 5.1 with camel
>> 1.3.x.x) that showed how to access a message in PAYLOAD mode:
>>
>> 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);
>> ....
>> }
>>
>> But it seems that the API has changed in the meanwhile since the
>> getMessage() method on CxfMessage class seems to no longer exist. What's
>> the
>> API for 1.5.1.1 to access the message ?
> I guess you can do
> 
> List<Element> elements = exchange.getIn().getBody(List.class);
> 
> But Willem is the best to answer.
> 
> You can always just get the body as Object and see which object it is.
> It should be somekind of Cxf List holder
> Object body = exchange.getIn().getBody();
> 
> and see if you can find your elements in that one.
> 
> 
> 
> 
>>
>> Best regards,
>> Mario
>> --
>> View this message in context:
>> http://www.nabble.com/PAYLOAD-access-API-changed-with-camel-from-camel-1.3.x.x-%3D%3E-1.5.1.1---tp22744147p22744147.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/PAYLOAD-access-API-changed-with-camel-from-camel-1.3.x.x-%3D%3E-1.5.1.1---tp22744147p22744944.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: PAYLOAD access API changed with camel from camel 1.3.x.x => 1.5.1.1 ?

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Mar 27, 2009 at 4:35 PM, mario_horny <ma...@dzbank.de> wrote:
>
> Hi guys,
>
> I'm using camel 1.5.1.1 coming with artix 5.5.
>
> I was trying to get back to a code snipped that Willem has provided to me a
> couple of months ago (back when I was still using artix 5.1 with camel
> 1.3.x.x) that showed how to access a message in PAYLOAD mode:
>
> 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);
> ....
> }
>
> But it seems that the API has changed in the meanwhile since the
> getMessage() method on CxfMessage class seems to no longer exist. What's the
> API for 1.5.1.1 to access the message ?
I guess you can do

List<Element> elements = exchange.getIn().getBody(List.class);

But Willem is the best to answer.

You can always just get the body as Object and see which object it is.
It should be somekind of Cxf List holder
Object body = exchange.getIn().getBody();

and see if you can find your elements in that one.




>
> Best regards,
> Mario
> --
> View this message in context: http://www.nabble.com/PAYLOAD-access-API-changed-with-camel-from-camel-1.3.x.x-%3D%3E-1.5.1.1---tp22744147p22744147.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus