Web服务请求类型转换问题

时间:2011-03-31 13:31:37

标签: c# asp.net web-services webservice-client

我有一个场景,我必须将数组列表传递给WebService。

WebService的:

 [WebMethod]    
   public void GetCommission(List<BOLibrary.Flight.DTContract> Loc)
    {
        CommissionManager test = new CommissionManager();
    }

客户端:

 List<BOLibrary.Flight.DTContract> BoList = new List<BOLibrary.Flight.DTContract>();
        BOLibrary.Flight.DTContract dtConboj = new BOLibrary.Flight.DTContract();
        dtConboj.ValidatingCarrier = "AA";
        DTContract[] loc1 =  BoList .ToArray();
        service.GetCommission(loc1);

当我尝试这样做时,我收到的异常无法将BOLibrary.Flight.DTContract转换为DTContract 这是因为当webservice创建proxey时,请考虑Type(DTContract)而不是namespace(BOLibrary.Flight.DTContract) 我必须传递BOLibrary.Flight.DTContract类型的列表或arraylist。

请帮助...... 在此先感谢...

1 个答案:

答案 0 :(得分:-1)

使用:GetCommission(DTContract[] Loc)

你试过拳击吗?

//Server
public void GetCommission(object oLoc) //or GetCommission(DTContract[] Loc)
{
List<BOLibrary.Flight.DTContract> Loc = oLoc as List<BOLibrary.Flight.DTContract>();

...
}

//Client
service.GetCommission(loc1 as object);