3

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

ありがとう!

4

1 に答える 1

6

@ResourceをwsContext変数に追加し、JaxWsServerFactoryBeanの使用に切り替える必要があります。

または、次を使用します。

PhaseInterceptorChain.getCurrentMessage()

現在のCXF内部メッセージを取得し、そこからヘッダーを取得します。

于 2010-05-20T22:01:44.917 に答える