Hessian, Adding a header

1.8k Views Asked by At

I am calling a Java method using Hessian, is it possible to also add HTTP headers before sending a message - so I can add "Authorization" to the header of the message?

I am using Spring, so I currently get a proxy bean and make the call on the proxy:

<bean id="beanRetrievalService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
  <property name="serviceUrl"       value="http://z.y.z/myService" />
  <property name="serviceInterface" value="x.y.z.MyInterface" />
</bean>
2

There are 2 best solutions below

0
On

You can't add a random header, but HTTP authentication is possible with Hessian. Here is how you would do it programmatically:

    HessianProxyFactory factory = new HessianProxyFactory();
    factory.setUser("neo");
    factory.setPassword("thereisnospoon");

    MyInterface service = (MyInterface) factory.create(MyInterface.class, "http://example.com/hessian/MyService");

I assume the Spring bean has similar setters for the username and the password.

0
On

Its also possible to propagate other implicite context information. However for this purpose some extensions of the Hesssian classes have to be done as e.g. described here: http://insidecoffe.blogspot.com/2012/02/hessian-wrapper-to-enable-context.html