开发者

Getting HTTP headers from Apache CXF POJO Service

开发者 https://www.devze.com 2022-12-30 20:14 出处:网络
what is the right method to get http headers from CXF POJO Service? I have folowing code, but it doesn\'t work:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消