【问题标题】:Getting HTTP headers from Apache CXF POJO Service从 Apache CXF POJO 服务获取 HTTP 标头
【发布时间】:2010-05-20 14:46:03
【问题描述】:

从 CXF POJO 服务获取 http 标头的正确方法是什么?

我有以下代码,但它不起作用:

ServerFactoryBean svrFactory = new ServerFactoryBean();
svrFactory.setServiceClass(TestService.class);
svrFactory.setAddress("http://localhost:8080/test");
svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
svrFactory.create();

public class TestService {

    protected javax.xml.ws.WebServiceContext wsContext;

    public void someMethod() {
       // the problem is that wsContext.getMessageContext() is null
    }
}

谢谢!

【问题讨论】:

    标签: http cxf pojo


    【解决方案1】:

    您需要将@Resource 添加到 wsContext 变量中,并切换到使用 JaxWsServerFactoryBean。

    或者,使用:

    PhaseInterceptorChain.getCurrentMessage()

    获取当前的 CXF 内部消息并从那里获取标题。

    【讨论】:

      猜你喜欢
      • 2012-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多