0

你好,这里有一节课...

公共类认证{

    private string userField;
    private string passwordField;
    public string user
    {
        get
        {
            return this.userField;
        }
        set
        {
            this.userField = value;
        }
    }

    public string password
    {
        get
        {
            return this.passwordField;
        }
        set
        {
            this.passwordField = value;
        }
    }

}

这里的网络服务:

[WebMethod]
public Vehicle[] getVehiculeList(Authentification authentification)
{
....
}

这里是客户端和 webservice 的调用:( 已经定义了与 webservice 中相同的类 Authentification)

Authentification azz = new Authentification() ;
azz.user = "toto";
azz.password = "tata";
string aa = ws.getVehiculeList(azz);

给出错误:错误 27 'WSCL.localhost.Service1.getVehiculeList(WSCL.localhost.Authentification)' 的最佳重载方法匹配有一些无效参数

错误 28 参数“1”:无法从“WSCL.Authentification”转换为“WSCL.localhost.Authentification”

有什么帮助吗?

非常感谢 !

4

1 回答 1

1

可能发生的情况是您在客户端上引用了包含数据实体(例如身份验证)的程序集,现在您拥有代理实体 ( WSCL.localhost.Authentification) 和原始服务器实体 ( WSCL.Authentification)。如果您将客户端对身份验证的使用更改为使用代理类 ( WSCL.localhost.Authentification),它应该可以工作。

如果您切换到 WCF,您将能够将身份验证等数据实体移动到单独的程序集中,然后在您的服务和客户端之间共享相同的类型。AFAIK 这在ASMX中不可能“开箱即用” 。

于 2012-01-26T20:02:40.140 回答