Getting HTTP headers from Apache CXF POJO Service
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!
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.
精彩评论