camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eduard Hildebrandt" <m...@eduard-hildebrandt.de>
Subject Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS
Date Mon, 07 Jul 2008 11:45:34 GMT
Hello all,

first of all I'd like to thank you for you good work. I'm really
enjoying working with Apache Camel.

I'd like to use Apache CXF with Apache Camel as transport and trying
to implement a webservice using SOAP over JMS. I'm thinking that I
identified some bugs in Apache Camel.

ISSUE #1:
First of all I tried to implement a CXF webservice _client_ using
Apache Camel as transport.
My code runs into a org.springframework.jms.MessageFormatException
(see attached stacktrace1.txt). According to JMS API Specification the
operation "getObjectProperty" supports only primitive values (see
http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Message.html). It's
not allowed to put an object of type java.lang.reflect.Method using
this method.

I pached this bug (see JmsBinding.java.patch) by converting all
non-primitive objects to a string. It's working now but the author of
the CXF component should really rethink if it's really necessary to
put all the unimportant header properties inside the message. Other
more important header properties like "SoapAction" are missing
instead.

In case you like to reproduce this issue, you can find my sample
project at http://family-hildebrandt.com/eduard/wp-content/uploads/serviceruntime.zip.
This project is configured to use TIBCO as JMS-Server. But you can use
ActiveMQ as well.

ISSUE #2:
The next issue was that the JMS-Components creates JMS-Messages based
on the object type. For example:

JmsBinding.java
221 if (body instanceof String) {
222   return session.createTextMessage((String)body);
223 }
224 if (body instanceof Serializable) {
225    return session.createObjectMessage((Serializable)body);
226 }

The CXF-Component puts an InputStream on the camel exchange:

CamelConduit.java
165 ex.getIn().setBody(outputStream.getInputStream());


For the JMS-Compontent it's an object type Serializable for this
reason it creates an JMS-ObjectMessage. But this is not the expected
behaviour of my service. I'm using SOAP over JMS and like to create a
JMS-TextMessage because the content is XML.

I solved this issue by implementing an own Processor and converting
the message content on camel exchange to a string (see
BodyProcessor.java). I think the better solution will be if the JMS
component allows to configure the JMS-Message-Type and/or the CXF
component puts an String to the camel exchange.

Now my client was sending correct requests (except the missing
"SoapAction" property). But this was not the end of the journey…

ISSUE #3:
The next issue was that the response message could not be associated
with the CXF service because the CXF context was missing. I pached
this (see CamelConduit.java.patch) by adding following line in
CamelConduit.java:

170 exchange.setProperty(CxfConstants.CXF_EXCHANGE, outMessage.getExchange());

After adding this line the response could be processed correctly.
However I'm not really sure if this is the right place for this and it
should be reviewed by the original author.

My client was working now. Hura! :-)

Next I wanted to implement the server side implementation of the
service as well with Apache CXF and Apache Camel as transport.

But now I'm stuck on a NullPointerException at
org.apache.camel.component.cxf.transport.CamelDestination.activate(CamelDestination.java:91)
(see stacktrace2.txt). The reason is that CamelTransportFactory does
not have a CamelContext even if I configure it in my spring
configuration. I think that CXF is using an own spring context and
does not use (or does not see) my camel context configuration.

Maybe I'm doing something wrong… Maybe a developer who is more
familiar with Apache CXF and Apache Camel can have a look at it. You
help is very appreciated.

Thank you very much!

Many greeting from Germany.

Best regards,

Eduard Hildebrandt

--
Meinen Weblog: http://www.eduard-hildebrandt.de



-- 
Meinen Weblog: http://www.eduard-hildebrandt.de

Mime
View raw message