On 05/13/2010 09:20 AM, William Tam wrote:
I had a quick chat with Willem. (thanks Willem) In this case, the
Camel converter framework will invoke the CxfPayload.toString() method
if no better suit converter is found. The toString method of
CxfPayload is as follow.
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append(getClass().getName());
buf.append(" headers: " + headers);
buf.append("body: " + body);
return buf.toString();
}
If the string output format is not what you expected, you can stick
with snippet that I sent before. Or, you can write a custom Camel
converter (http://camel.apache.org/type-converter.html). I will
resolve the Jira as "not fix".
Oh, if the string format is not what you expected and you don't want to
write a Camel converter. The snippet needs some slight modification
because the string return is never null.
Message message = exchange.getIn();
String request = null;
CxfPayload payload = message.getBody(CxfPayload.class);
if (payload != null) {
request = getRequestFromSource(payload.getBody());
} else {
request = message.getBody(String.class);
}
Obviously. writing a custom converter is a more elegant solution.
Hopefully, the default string format is acceptable to you already.
Thanks,
William
Thanks,
William
On 05/13/2010 08:44 AM, Willem Jiang wrote:
Hi William
Current camel supports to turn the CxfPayLoad object into a String,
as Camel converter will call the CxfPayLoad.toString() method to do
this kind job.
But if you just want to get the payload body, I'm afraid you still
need to use the below code to do the job.
Willem
William Tam wrote:
I need to correct my previous reply. Are you using PAYLOAD or POJO
mode? (I assume you are using PAYLOAD.) The body is a CxfPayload
object which contains a list DOM elements. The snippet would like
this instead.
Message message = exchange.getIn();
String request = message.getBody(String.class);
// We don't need the follow once we have a converter for
CxfPayload-> String
if (request == null) {
CxfPayload payload = message.getBody(CxfPayload.class);
if (payload != null) {
request = getRequestFromSource(payload.getBody());
}
}
The getRequestFromSource(List<Element>) method takes a list of
Element and convert them to a String. I created a Jira for adding a
converter that converts a CxfPayload to a String so it is not needed
in the future.
(https://issues.apache.org/activemq/browse/CAMEL-2714)
On 05/12/2010 11:54 AM, William Tam wrote:
You can do something like this:
Message message = exchange.getIn();
String request = message.getBody(String.class);
if (request == null) {
Source source = message.getBody(Source.class);
if (source != null) {
request = getRequestFromSource(source);
}
}
If we had a converter to covert from CXF payload to string, we
wouldn't the logic in "if (request == null)".
On 05/12/2010 11:24 AM, fjaouen wrote:
With 1.5.0 I was checking the instance of Exchange in a process
method to
know if I have a CxfMessage or a JMSMessage in order to do different
treatment.
if (aExchange instanceof JmsExchange) {
JmsMessage jmsMessage = (JmsMessage) aExchange.getIn();
String request = jmsMessage.getBody(String.class);
...
}
else if (aExchange instanceof CxfExchange) {
CxfMessage cxfMessage = (CxfMessage) aExchange.getIn();
Source source = cxfMessage.getBody(Source.class);
String request = getRequestFromSource(source);
...
}
So now how can I do this check ? On which object may I determine
that I
receive a CXF or a JMS ?
Thank you !
hzbarcea wrote:
All DefaultExchange specializations were removed in 2.0.0. What
seemed a good idea initially proved to be unnecessary. This has
been
communicated in the 2.0.0 Release Note [1]: "Exchange api cleanup.
Complete removal of specialized Exchange using generics."
The specialized Messages were preserved as they may deal with
specialized types of body (payloads). You need use the
DefaultExchange instead of CxfExchange. If you have any issues
don't
hesitate to ask.
Cheers,
Hadrian
[1] http://camel.apache.org/camel-200-release.html
On Nov 13, 2009, at 1:31 PM, fjaouen wrote:
Hi there,
I am currently using Camel 1.5.0 and I am trying to make a
migration
to
2.0.0 version.
It seems that org.apache.camel.component.cxf.CxfExchange class
is not
anymore available in this new version ?
What is its remplacement ?
Is there an easy way to know what has been removed in this new
version or a
documentation explaining how to migrate these changes ?
Thank you !
--
View this message in context:
http://old.nabble.com/CxfExchange-is-not-anymore-available-in-Camel-2.0.0-tp26341178p26341178.html
Sent from the Camel Development mailing list archive at Nabble.com.