I have Stateless EJB WebService.
WS interface:
@Remote
@WebService
public interface WSInterface{
@WebMethod
public String[] WSMethod(@WebParam(name="arg0") String arg0)
}
WS implementation:
@WebService
@Stateless
public class WSImpl extends GenericSessionBean implements WSInterface {
@WebMethod
public String[] WSMethod( String arg0)
{
return ...;
}
}
And i need to get client IP in WSMethod. I tried to get it by this way (it works in "common" webservice):
@Resource
private SessionContext ctx;
public String[] getProperties() {
List propList = new ArrayList();
MessageContext mc = ctx.getMessageContext();
Iterator props = mc.getPropertyNames();
for (String prop = (String)props.next(); props.hasNext(); prop = (String)props.next())
{ propList.add(prop); }
return propList.toArray(new String[propList.size()]);
}
But no success: there is no property with name REMOTE_ADDR
in MessageContext
.
Is there any way to get REMOTE_ADDR
in @Stateless
EJB?
Can you try to obtain a WebServiceContext instead of SessionContext with @Resource? I've no appropriate env to check it up right now