Glen Mazza wrote:
Thanks, Willem, but why would
String response = e.getIn().getBody(String.class);
consume the response? Why does Camel delete the response when you call
getBody()?
No, Camel didn't delete the response.
It's just because the body instance is an instance of InputStream, and
it can't be read twice.
You can find more information about it here[1]
Also, for your second solution, why does converting the Body to a String
result in the above call *not* consuming it anymore? Camel seems highly
arbitrary in the way it works.
Turn the message body into String could make the message body be
reread-able.
[1]http://camel.apache.org/stream-caching.html
Willem
Thanks,
Glen
Willem Jiang wrote:
Hi Glen,
That's because your SOAPResponseReader consumer the response.
you just need to put the Body back as a string like this
public class SOAPResponseReader implements Processor {
@Override
public void process(Exchange e) {
String response = e.getIn().getBody(String.class);
System.out.println("This was returned - Body: " +
response);
e.getIn().setBody(response);
}
}
Or just turn the Body into String like this
from("jms:queue:numbersToDouble")
.process(new SOAPMessagePreparer())
.to(CXF_URI)
.convertBodyTo(String.class)
.process(new SOAPResponseReader())
.to("file://testfile");
Willem
Glen Mazza wrote:
Hello, the following route makes SOAP client calls and places the
SOAP responses in files in the given testfile folder:
public void configure() {
from("jms:queue:numbersToDouble")
.process(new SOAPMessagePreparer())
.to(CXF_URI)
// .process(new SOAPResponseReader())
.to("file://testfile");
}
Everything works fine. But when I place a process method between the
latter two "to" methods (i.e., uncomment the line above), the process
method will read properly the SOAP response but it seems to "eat" it
so that only blank files end up subsequently getting written to the
testfile folder.
Here's my SOAPResponseReader:
public class SOAPResponseReader implements Processor {
@Override
public void process(Exchange e) {
System.out.println("This was returned - Body: " +
e.getIn().getBody(String.class));
}
}
Any idea what's happening? What do I need to do to
SOAPResponseReader so that the final to("file://testfile") in the
route will store the SOAP response in each file again?
Thanks,
Glen