C# .NET 2.0 webservice未返回数据表

C# .NET 2.0 webservice未返回数据表,c#,asp.net,web-services,mono,datatable,C#,Asp.net,Web Services,Mono,Datatable,我有一个webservice方法,定义如下: [WebMethod] public DataTable GetResponseCodeTypes() { // connect to database and retrieve results, // then populate and return a DataTable } 该方法已通过webservice测试表单进行验证,并按预期返回一个DataTable: <?xml version="1.0" encoding="utf-

我有一个webservice方法,定义如下:

[WebMethod]
public DataTable GetResponseCodeTypes()
{
  // connect to database and retrieve results,
  // then populate and return a DataTable
}
该方法已通过webservice测试表单进行验证,并按预期返回一个
DataTable

<?xml version="1.0" encoding="utf-8"?>
<DataTable xmlns="http://tempuri.org/">
  <DocumentElement xmlns="">
    <ResponseCodeTypes>
      <CodeTypeId>1</CodeTypeId>
      <Descrip>RPC</Descrip>
    </ResponseCodeTypes>
    <ResponseCodeTypes>
      <CodeTypeId>2</CodeTypeId>
      <Descrip>Non-RPC</Descrip>
    </ResponseCodeTypes>
    <ResponseCodeTypes>
      <CodeTypeId>3</CodeTypeId>
      <Descrip>No connect</Descrip>
    </ResponseCodeTypes>
  </DocumentElement>
</DataTable>

1.
RPC
2.
非RPC
3.
无连接
但是,当我从C#frontend代码调用
GetResponseCodeTypes
方法时,它不仅返回
DataSet
而不是
DataTable
,而且返回的
DataSet
包含零个表

然后,我修改了存根类(在添加web引用时由Visual Studio生成)以返回一个
DataTable
。这是可行的,因为我确实得到了一个
DataTable
返回-但是说
DataTable
没有定义任何列或行

我知道在.NET1.x中,不可能从webservice方法返回
数据表
(您必须将其包装到
数据集
),但我觉得这在.NET2.x中是固定的

这里的问题是什么

编辑:

webservice是.NET 2.0,运行在Mono 2.4.2.3下的Linux机器上;当前端代码在运行VS2008和SP1的Windows XP计算机上的.NET 2.0中开发时。

请参见此链接

请注意,DataTable本身 支持Web服务,这是唯一的选择 这是代理的一代, 创建代理后,在运行时, 可以传递DataTable实例 关于使用Web服务

对于过渡期,您可以选择 以下任一解决方法:

A) 手动创建客户端 每个Web服务的代理类 使用数据表

(B)

  • 编译并GAC附加的SchemaImporterex文件
  • 使用以下命令将其添加到machine.config中的现有扩展 完全限定程序集名称

  • 使用标准机制(如xsd.exe或Visual Studio)生成 客户端代理类


  • 通常,您不应返回
    数据表
    数据集
    ,或任何其他特定于.NET的类型。当然,它们只适用于.NET客户端。

    谢谢Ramesh-我尝试过,但对VS/wsdl.exe生成的代理类没有任何影响。我用更多的信息编辑了我的原始帖子,这可能是Mono造成的问题吗?这不是问题,因为我知道事实上除了.NET之外,Web服务永远不会被其他任何东西使用。