【问题标题】:error when calling the webservice调用网络服务时出错
【发布时间】:2010-03-29 14:17:29
【问题描述】:

我通过调用 web 服务来获取 pagepack 助手的列表。我已经添加了网络参考。

using org.xerox.xde3.na.sdi.amiller_v_vista;
public org.xerox.xde3.na.sdi.amiller_v_vista.DDCControl proxy;

在页面加载方法中我调用web方法如下

proxy = new DDCControl();

Guid y = new Guid("45a5b1c2-2fa5-4136-abdd-bc213b694848");

DataList1.DataSource = proxy.GetAllDDCs(this.AccountID, y);

DataList1.DataBind();

我收到以下错误:

DataList1 使用了无效的数据源。有效的数据源必须实现 IListSource 或 IEnumerable

public DDCReturnGetAll GetAllDDCs(Guid accountId, Guid authToken);

GetAllDDCs 的返回类型是 DDCReturnGetAll

在哪里

public class DDCReturnGetAll : DDCReturnBase 

{ public DDCReturnGetAll(); 

public DDCInfo2[] DDCs { get; set; } } 

在哪里

DDCInfo2 是

public class DDCInfo2 { public DDCInfo2(); 

public BrandingType brandingType { get; set; } 

public string ChargebackName { get; set; } 

public string CollectorName { get; set; } 

public string Description { get; set; } 

public string URL { get; set; } }

你能帮我解决这个问题吗?

【问题讨论】:

  • GetAllDDCs 返回的类型是什么?查看对象浏览器窗口以查看它在客户端上返回的内容。还告诉我们它在服务器上返回了什么。
  • 你能展示 DDCControl 的部分代码吗?
  • GetAllDDCs的返回类型是DDCReturnGetAll where public class DDCReturnGetAll : DDCReturnBase { public DDCReturnGetAll();公共 DDCInfo2[] DDCs { 获取;放; } } 其中 DDCInfo2 是 public class DDCInfo2 { public DDCInfo2();公共 BrandingType 品牌类型 { 获取;放; } 公共字符串 ChargebackName { 获取;放; } 公共字符串 CollectorName { 获取;放; } 公共字符串描述 { 获取;放; } 公共字符串 URL { 获取;放; } }

标签: c# web-services asmx


【解决方案1】:

从 GetAllDDCs 返回的对象没有实现 IListSource 或 IEnumerable。返回的对象很可能有一个属性,您应该绑定到它。

【讨论】:

    【解决方案2】:

    您需要查看 procy.GetAllDDCs 方法的返回类型并查看它返回的内容。

    您收到的错误消息表明 DataList1 控件找不到枚举要绑定的项的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多