0

我正在使用 Hessian 调用 Java 方法,是否可以在发送消息之前添加 HTTP 标头 - 所以我可以在消息的标头中添加“授权”?

我正在使用 Spring,所以我目前获得了一个代理 bean 并在代理上进行调用:

<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>
4

2 回答 2

3

它也可以传播其他隐含的上下文信息。然而,为此目的,必须对 Hesssian 类进行一些扩展,如此处所述:http: //insidecoffe.blogspot.com/2012/02/hessian-wrapper-to-enable-context.html

于 2012-02-03T16:35:32.797 回答
0

您不能添加随机标头,但可以使用 Hessian 进行 HTTP 身份验证。这是您以编程方式执行此操作的方法:

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

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

我假设 Spring bean 具有类似的用户名和密码设置器。

于 2011-11-07T11:16:30.980 回答