You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Harald Wellmann <ha...@gmx.de> on 2011/03/13 17:11:33 UTC

Remoting via HTTP and Jetty

I'm trying to set up a simple example with Spring remoting via HTTP, and 
I'm not sure if my configuration or my assumptions are wrong, or if 
there's a problem in the Camel HTTP component.

Essentially, my setup is similar to the camel-example-spring-jms with 
CamelClientRemoting, only I'm using HTTP instead of JMS as transport.

On the client side, I'm creating a proxy for a HelloService service 
interface using a CamelProxyFactoryBean, using the remote HTTP endpoint 
as serviceUrl, e.g. http://localhost:9999/hello.

Now when starting the Camel context, I'm getting the following exception:

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type 
converter available to convert from type: 
org.apache.camel.component.bean.BeanInvocation to the required type: 
java.io.InputStream with value BeanInvocation public abstract void 
com.blogspot.hwellmann.camel.greeter.api.HelloService.sayGoodbye(com.blogspot.hwellmann.camel.greeter.api.Person) 
with [com.blogspot.hwellmann.camel.greeter.api.Person@1badd463]]
	at 
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:143) 
~[camel-core-2.6.0.jar:2.6.0]
	at 
org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100) 
~[camel-core-2.6.0.jar:2.6.0]
	... 31 common frames omitted


It seems the HTTP component is unable to convert the BeanInvocation 
object to anything that can be written to the HTTP Request.

As a workaround, I'm now connecting my proxy to a direct endpoint with 
an intermediate XStream marshaller like this:

  	from("direct:start")
             .marshal().xstream()
             .to("http://localhost:9999/hello");

and on the server side:

         from("jetty:http://0.0.0.0:9999/hello").
             unmarshal().xstream().
             to("helloService");

Is there a way to avoid the marshaller and simply use serialized objects?

Best regards,
Harald

Re: Remoting via HTTP and Jetty

Posted by Harald Wellmann <ha...@gmx.de>.
Am 14.03.2011 19:48, schrieb Claus Ibsen:
> Hi Harald
>
> Nice blog btw on the JMS.
>

Thanks :-)

> I remember adding support for serialized objects over HTTP recently.
> Basically you need to set the content-type to indicate that. Let me
> find an unit test.
> https://svn.apache.org/repos/asf/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java
>
> This is the content-type
> application/x-java-serialized-object
>
> And you need Camel 2.6
>
>

Actually, that's one of the things I've already tried, using a route 
like this:

         from("direct.start")
             .setHeader(Exchange.CONTENT_TYPE, 
constant(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT))
             .to("http://localhost:9999/hello");


Setting the header, I can send a message for my proxy method invocation, 
but then there's another issue with the reply message:

For all proxy methods with a void return type, I get an EOFException 
when processing the reply. Non-void return types like String are ok, though.

It seems setting the header implies that the HTTP Response is also 
treated like a serialized object, and the case "empty response = void 
return" is missing somehow...

Best regards,

Harald

Re: Remoting via HTTP and Jetty

Posted by Claus Ibsen <cl...@gmail.com>.
Hi Harald

Nice blog btw on the JMS.

I remember adding support for serialized objects over HTTP recently.
Basically you need to set the content-type to indicate that. Let me
find an unit test.
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/javabody/HttpJavaBodyTest.java

This is the content-type
application/x-java-serialized-object

And you need Camel 2.6



Btw a bit related if your proxy is simple then you can send the data
as plain text and still have a proxy:
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/proxy/





On Sun, Mar 13, 2011 at 5:11 PM, Harald Wellmann <ha...@gmx.de> wrote:
> I'm trying to set up a simple example with Spring remoting via HTTP, and I'm
> not sure if my configuration or my assumptions are wrong, or if there's a
> problem in the Camel HTTP component.
>
> Essentially, my setup is similar to the camel-example-spring-jms with
> CamelClientRemoting, only I'm using HTTP instead of JMS as transport.
>
> On the client side, I'm creating a proxy for a HelloService service
> interface using a CamelProxyFactoryBean, using the remote HTTP endpoint as
> serviceUrl, e.g. http://localhost:9999/hello.
>
> Now when starting the Camel context, I'm getting the following exception:
>
> Caused by: org.apache.camel.NoTypeConversionAvailableException: No type
> converter available to convert from type:
> org.apache.camel.component.bean.BeanInvocation to the required type:
> java.io.InputStream with value BeanInvocation public abstract void
> com.blogspot.hwellmann.camel.greeter.api.HelloService.sayGoodbye(com.blogspot.hwellmann.camel.greeter.api.Person)
> with [com.blogspot.hwellmann.camel.greeter.api.Person@1badd463]]
>        at
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:143)
> ~[camel-core-2.6.0.jar:2.6.0]
>        at
> org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:100)
> ~[camel-core-2.6.0.jar:2.6.0]
>        ... 31 common frames omitted
>
>
> It seems the HTTP component is unable to convert the BeanInvocation object
> to anything that can be written to the HTTP Request.
>
> As a workaround, I'm now connecting my proxy to a direct endpoint with an
> intermediate XStream marshaller like this:
>
>        from("direct:start")
>            .marshal().xstream()
>            .to("http://localhost:9999/hello");
>
> and on the server side:
>
>        from("jetty:http://0.0.0.0:9999/hello").
>            unmarshal().xstream().
>            to("helloService");
>
> Is there a way to avoid the marshaller and simply use serialized objects?
>
> Best regards,
> Harald
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/