webService请求类型转换问题

发布于 2024-10-28 03:30:40 字数 912 浏览 4 评论 0原文

我有一个场景,我必须将数组列表传递给 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 转换为 的异常DT合约 这是因为当 webservice 创建代理时考虑 Type(DTContract) 而不是 namespace(BOLibrary.Flight.DTContract) 我必须传递 BOLibrary.Flight.DTContract 类型的列表或数组列表。

请帮忙... 提前致谢...

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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

权谋诡计 2024-11-04 03:30:40

使用: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);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文