无法获取HttpExchange对象

时间:2016-03-22 12:08:33

标签: java web-services jax-ws

为了基于应用程序(而不是在servlet中)编写简单的Web服务,我在以下代码的最后一行获得了 NullPointerException

@Resource WebServiceContext wsContext;

// ...

MessageContext mc = wsContext.getMessageContext();
// HttpExchange exchange = (HttpExchange) mc.get("com.sun.xml.internal.ws.http.exchange");    // solution 1
HttpExchange exchange = (HttpExchange) mc.get("com.sun.xml.ws.http.exchange");    // solution 2
InetSocketAddress remote = exchange.getRemoteAddress();

我尝试了解决方案1和解决方案2,结果相同。在这两种情况下, exchange 对象都为空。

如何获取交换对象?我在JDK 1.6上使用jax-ws。

0 个答案:

没有答案