9 Replies Latest reply on Oct 3, 2007 4:07 AM by richard_opalka

    Error getting WebServiceContext/MessageContext information i

    djhititup

      Below is my web service code:

      package com.company.department.ws;

      import java.rmi.RemoteException;
      import java.util.Map;
      import javax.annotation.Resource;
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.xml.ws.handler.MessageContext;
      import javax.xml.ws.WebServiceContext;

      @WebService(name="TestWebService", targetNamespace="http://www.company.com/department/testwebservice/", serviceName="TestWebService")
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      public class TestWebService {

      @Resource WebServiceContext wsContext;

      @WebMethod
      public String hello(String name) {
      return "Servlet WS: " + wsContext.getUserPrincipal() + ": " + name;
      }
      }


      When being invoked the exception below is returned:

      16:02:49,552 ERROR [SOAPFaultExceptionHelper] SOAP request exception
      java.lang.NullPointerException
      at com.company.department.ws.TestWebService.hello
      (TestWebService.java:20)

      The error is happening on the "wsContext.getUserPrincipal()". I feel the the wsContext object is not being set when the service is invoked. I'm at a lost as to what is needed. The end goal of this web service is to pull cookie information from the HTTPRequest object. Please help.