Hello All,
I have set up a simple HTTP service using Jetty that acts similar to a REST
endpoint and servers up XML responses.  The service works just fine and I am
trying to add some unit tests to it.

I have set up a simple producer template test and tried this:

File inputFile = new File("someFile.xml");
String returnValue = template.requestBody("http://localhost:8081/REST";,
inputFile, String.class);
log.debug("value: " + returnValue + "END");

However, I get no return value.

I have also tried to return an object and I get back :
org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream

If I try to cast this, I get this issue:
org.apache.camel.converter.stream.CachedOutputStream$WrappedInputStream
cannot be cast to org.apache.camel.converter.stream.CachedOutputStream

I also tried setting the stream caching to true:
context.setStreamCaching(true);

but that has no affect.

I know the service is getting invoked and is returning a proper return
value.  I just can't get at it with the producer template.

Any idea how I can use the producer template to do a request/reply against
an HTTP endpoint and get the response as a string, file, or other useable
format?

>From what I understand, I need to use template.request.

This would be easy enough to do in a Camel Route with a convertBodyTo
java.lang.String, however I am writing a unit test so I just want to use the
producer template.

Thanks,
Yogesh


--
View this message in context: 
http://camel.465427.n5.nabble.com/Producer-Template-to-Invoke-HTTP-Endpoint-Request-Reply-tp5684220.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to