2012-01-26 192 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中不可能「開箱即用」。