我的函数如下:    [WebMethod]
    public bool FindLoginUsers(string loginid)
    {
            DataClassesDataContext sd = new DataClassesDataContext();
            var query = from p in sd.LoginUsers
                        where p.LoginId == loginid
                        select p;
            if (query.Count()!= 0)
            {
                return true;
            }
            else
            {
                return false;
            }
    }
可是在使用的时候,不能这样:bool s;
WebServiceSoapClient client = new WebServiceSoapClient();
s=client.FindLoginUsersAsync("admin");

解决方案 »

  1.   

    你添加web reference,会生成这个web service的代理类,你直接使用这个代理类。
      

  2.   

    添加web引用,还不行的,代码再加一下默认凭证
      

  3.   

    去搜一下WebService的例子,多的是~
      

  4.   

    WEBSEVICE的最终返的数据都是XML,然后通过WDSL解析的。
    你最好还是返回STRING,然后在CLIENT端CONVERT
      

  5.   

    String我也试过了,提示String和Void类型不兼容
      

  6.   


    [WebMethod]
        public string FindLoginUsers(string loginid)
        {
               string result="false";              DataClassesDataContext sd = new DataClassesDataContext();
                var query = from p in sd.LoginUsers
                            where p.LoginId == loginid
                            select p;
                if (query.Count()!= 0)
                {
                    result ="true";
                }
                return result
                
        }
      

  7.   

    to   l13873666736
    错误信息如下:
    Error 1 Cannot implicitly convert type 'void' to 'string'
      

  8.   

    是你環境有問題吧
    [WebMethod]
        public string FindLoginUsers(string loginid)
        {
               string result="false";           return result;
                
        }
      

  9.   

    <?xml version="1.0" encoding="utf-8" ?> 
      <string xmlns="http://tempuri.org/">false</string>
      

  10.   

    本来是同步方法FindLoginUsers,你用FindLoginUsersAsync异步方法调用的?
    代理类中没有FindLoginUsers方法吗?
      

  11.   

    是不是你写了方法后没有对web再更新引用?
    选中当前添加引用的webservice,选择“更新引用”然后再次编译就行了!
      

  12.   

    你改的WEBService后要重新更新WS的引用..你第一次应该是Void的方法吧?