webService Request Type Casting Problem

自古美人都是妖i 提交于 2019-12-12 01:47:53

问题


I have a scenario where i have to pass the array list to the WebService.

WebService:

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

Client:

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

when i am trying to do this i am getting the exception that cannot convert the BOLibrary.Flight.DTContract to DTContract This is because when webservice create proxey consider Type(DTContract) not namespace(BOLibrary.Flight.DTContract) and i have to pass the list or arraylist of BOLibrary.Flight.DTContract Type.

please Help... Thanks in Advance...


回答1:


Use: GetCommission(DTContract[] Loc)

Did you try boxing it?

//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);


来源:https://stackoverflow.com/questions/5500669/webservice-request-type-casting-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!