2012-01-26 190 views
0

你好复杂的参数调用Web服务,这是一类...与C#客户端

公共类身份认证 {

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; 
     } 
    } 

} 

这里的Web服务:

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

这里客户端和webservice的调用: (在web服务的相同类身份认证等已被定义)

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'

有什么帮助吗?

非常感谢!

回答

1

什么可能发生的是,你已引用包含您的客户端上的数据实体(例如身份验证)的装配,现在你有两个代理实体(WSCL.localhost.Authentification)和原始服务器实体(WSCL.Authentification)。如果您更改客户端的身份验证使用代理类(WSCL.localhost.Authentification)它应该工作。

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