@WebService
public class WebService {
@Resource
WebServiceContext wsc;
@WebMethod
public String webMethod() {
MessageContext mc = wsc.getMessageContext();
HttpServletRequest req = (HttpServletRequest)
mc.get(MessageContext.SERVLET_REQUEST);
return "Client: " +
req.getRemoteHost() + " (" +
req.getRemoteAddr() + ").";
}
}
The code above will return the host and IP-address of the remote web service client back to the client.
Client Code Please ,
ReplyDeletei got null pointer exception (wsc.),