从 Apache CXF POJO 服务获取 HTTP 标头
从 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
}
}
谢谢!
what is the right method to get http headers from CXF POJO Service?
I have folowing code, but it doesn't work:
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
}
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 @Resource 添加到 wsContext 变量上,并切换到使用 JaxWsServerFactoryBean。
或者,使用:
PhaseInterceptorChain.getCurrentMessage()
获取当前 CXF 内部消息并从中获取标头。
You would need to add an @Resource onto the wsContext variable and also switch to using the JaxWsServerFactoryBean.
Alternatively, use:
PhaseInterceptorChain.getCurrentMessage()
to get the current CXF internal message and grab the headers off there.