[英]Get Client IP in Stateless EJB
I have Stateless EJB WebService. 我有无状态EJB WebService。
WS interface: WS介面:
@Remote
@WebService
public interface WSInterface{
@WebMethod
public String[] WSMethod(@WebParam(name="arg0") String arg0)
}
WS implementation: WS实现:
@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. 而且我需要在WSMethod中获取客户端IP。 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
. 但是没有成功:
MessageContext
没有名称为REMOTE_ADDR
属性。
Is there any way to get REMOTE_ADDR
in @Stateless
EJB? 有什么方法可以在
@Stateless
EJB中获得REMOTE_ADDR
?
Can you try to obtain a WebServiceContext instead of SessionContext with @Resource? 您可以尝试使用@Resource获取WebServiceContext而不是SessionContext吗? I've no appropriate env to check it up right now
我没有适当的环境立即检查
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.