Am Mittwoch, den 09.04.2008, 11:04 +0100 schrieb James Strachan:
> On 09/04/2008, Glen Mazza <[EMAIL PROTECTED]> wrote:
> > Thanks Willem, one more question, looking at the sample code you linked
> >  to below:
> >
> >  public void testInvokingJawsServerWithParams() throws Exception {
> >         CxfExchange exchange =
> >  (CxfExchange)template.send(getJaxwsEndpointUri(), new Processor() {
> >             public void process(final Exchange exchange) {
> >                 final List<String> params = new ArrayList<String>();
> >                 params.add(TEST_MESSAGE);
> >                 exchange.getIn().setBody(params);
> >                 exchange.getIn().setHeader(CxfConstants.OPERATION_NAME,
> >  GREET_ME_OPERATION);
> >             }
> >         });
> >
> >         org.apache.camel.Message out = exchange.getOut();
> >         Object[] output = (Object[])out.getBody();
> >         LOG.info("Received output text: " + output[0]);
> >         assertEquals("reply body on Camel", "Hello " + TEST_MESSAGE,
> >  output[0]);
> >     }
> >
> >  The "params" in "exchange.getIn().setBody(params);" above will come from
> >  the numbers being fed to the queue, with one web service call for each
> >  number fed in.  But how can I access (obtain) the numbers being fed into
> >  the queue from within that process(final Exchange exchange) override
> >  above?
> 
> You can access the parameters (i.e. message body) via
> 
> exchange.getIn().getBody();
> 

(Newbiespeak) So what you're saying here is that once I set a route from
the message queue to the web service, the Exchange parameter passed into
the web service will be already be prepopulated with the number
(getBody()) that was passed into the queue?  If so, cool!


> if you want to try convert the body to a certain Java type, such as a 
> String...
> 
> String body = exchange.getIn().getBody(String.class);

Good.  Thanks!

Glen

> 
> This will then invoke the type converter mechanism to try convert to
> the correct type (or return null if it could not be converted).
> http://activemq.apache.org/camel/type-converter.html
> 

Reply via email to