• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException Trying to Get RemoteIP (why?)  RSS feed

 
sam nit
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to get the client IP for one of the methods in the web service, but the stated directions I've found don't seem to work.
my webservice is very simple.

@Resource
WebServiceContext wsContext;

@Resource
public final void setWebContext(final WebServiceContext wsContext) {
System.out.println( "wsContext is null " + wsContext == null );
this.wsContext = wsContext;
}



@WebMethod
public String yekMethod(String s ){
MessageContext msgCtxt =/*--> wsContext is null */wsContext.getMessageContext();
HttpServletRequest req = (HttpServletRequest) msgCtxt
.get(MessageContext.SERVLET_REQUEST);
String clientIP = req.getRemoteAddr();
System.out.println(clientIP);
return s;
}

I try to use all directions said in similar topic like this:
http://www.coderanch.com/t/485627/Web-Services/java/NullPointerException-Trying-RemoteIP-why
but the problem is not solved.
My application server is weblogic 10.3.1.0 and I use ant task for generating webservice artifacts (like wsdl, web.xml).

any idea?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!