【发布时间】:2016-02-07 10:48:33
【问题描述】:
我有无状态 EJB WebService。
WS接口:
@Remote
@WebService
public interface WSInterface{
@WebMethod
public String[] WSMethod(@WebParam(name="arg0") String arg0)
}
WS 实现:
@WebService
@Stateless
public class WSImpl extends GenericSessionBean implements WSInterface {
@WebMethod
public String[] WSMethod( String arg0)
{
return ...;
}
}
我需要在 WSMethod 中获取客户端 IP。 我试图通过这种方式得到它(它在“通用”网络服务中工作):
@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()]);
}
但没有成功:MessageContext 中没有名称为 REMOTE_ADDR 的属性。
有没有办法在@Stateless EJB 中获取REMOTE_ADDR?
【问题讨论】:
标签: java web-services ejb stateless