[Mono-aspnet-list] When a web method returns DataTable the method generated in proxy class returns DataSet (Bug #360541)

Jan van der watt janvanderwatt at gmail.com
Thu Apr 16 19:42:16 EDT 2009


Hi,

https://bugzilla.novell.com/show_bug.cgi?id=360541 indicates that this
problem was fixed, but I still see it on my Mono (2.4).

Am I doing something wrong, or must I "re-open" the bug?

Sample code below with extra details.

Thanks!

Jan



[WebServiceDataTable.asmx]
======================
<%@ WebService Language="C#" Class="WebServiceDataTable" %>

using System;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebServiceDataTable  : System.Web.Services.WebService {

    [WebMethod]
    public bool HelloWorld(out DataTable result) {
        result = new DataTable("Name of table");
        return ( true );
    }

}

[TestWebServiceDataTable.aspx]
========================
<%@ Page Language="C#" %>

<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    // ===========================================================================
    // MAIN ENTRY
    //
    protected void Page_Load(object sender, EventArgs e) {
        localhost.WebServiceDataTable ws = new localhost.WebServiceDataTable();
        DataTable table;
//
// Compiler error occurs on this line:
//
        bool success = ws.HelloWorld(out table);
        outcome.InnerHtml = "Success: Table name = " + table.TableName;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>DataTable over WebService</title>
</head>
<body>
    <div id="outcome" runat="server">
    </div>
</body>
</html>

You will get this error:

"The best overloaded method match for
`localhost.WebServiceDataTable.HelloWorld(out System.Data.DataSet)'
has some invalid arguments" where the code is called:

            DataTable table;
            bool success = ws.HelloWorld(out table);

As you can see, I supply a DataTable, but the error message implies I
should have supplied a DataSet. The web service definition is:

    [WebMethod]
    public bool HelloWorld(out DataTable result) { ... }

which obviously doesn't specify a DataSet.

On MS.NET, this works fine.

To verify the parameter type on MS.NET, I specifically passed an
incorrect type as parameter, e.g.

    bool success = ws.HelloWorld(out result /* type is STRING, not
DataTable*/ );

and I get:

"The best overloaded method match for
'localhost.WebServiceDataTable.HelloWorld(out System.Data.DataTable)'
has some invalid arguments", which proves that MS.NET uses DataTable
for the parameter type, as expected.


More information about the Mono-aspnet-list mailing list