我要的功能是想知道用户两次使用web service的是不是同一台机器。
其实就是在限制用户只能在一台计算机上使用web service。
功能就同session + cookie

解决方案 »

  1.   

    Web Service本来就是依附于Web Server的,
    所以当然也可以用Servlet对象解决这些问题。
      

  2.   

    usabcd(9号公路上的3名共军):
     能举个例子?
      

  3.   

    跟普通的应用一样,有2种方式,可根据你的具体情况选择,一种是判断IP是否一样,
    另外一种是判断Cookie,
    你可以在Web Serivice中得到HttpServletRequest对象,
    如果你使用的是Axis 可以这样得到:
    MessageContext context = MessageContext.getCurrentContext();
    HttpServletRequest req = (HttpServletRequest) context.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);然后便可以按往常的做法处理了。
    不过,这些都不是很严谨的方法。因为IP是可以变化的。cookie也是可以清掉的
      

  4.   

    用Axis和Tomcat4.1
    我写了一个jws文件调用jar包里的一个方法。现在想不能用IP,因为可能得不到代理上网的IP。
    改用网卡ID,当然,这也不是很严谨的,黑客也是可以修改网卡ID的。
    我写了简单的java类,
    package jwstest;import org.apache.axis.MessageContext;public class Test()
    {
       public Test()
       {
       }
       public String getSession()
       {
          MessageContext context = MessageContext.getCurrentContext();
          //......
          String session_ID = null;
          return session_ID;
       }
    }
    在package报错:
    The type of javax.xml.rpc.hander.soap.SOAPMessageContext cannot be resolved. It is indirectly referenced from required. class.files.
    我的jws文件放在项目的根目录下:
    WsTest.jws
    import jwstest.*;
    public class WsTest()
    {
      public String getSessionID()
     {
        Test test = new Test();
        return test.getSessionID();
     }
    }