all groups > dotnet web services > february 2007 >
You're in the

dotnet web services

group:

Web Service Method Can't return a DataTable?



Web Service Method Can't return a DataTable? Joseph Geretz
2/20/2007 10:31:22 PM
dotnet web services: I don't get it. A DataTable can't be returned, but a DataSet can. Yet a
DataSet contains one or more DataTables. So obviously a DataTable must be
serializable. So why not just let me return a DataTable?

Thanks for your advice,

- Joe Geretz -

RE: Web Service Method Can't return a DataTable? Manish Bafna
2/20/2007 11:46:03 PM
Hi,
In .NET 2.0 even DataTable is serializable.

Thanks and Regards,
Manish Bafna.
MCP and MCTS.

[quoted text, click to view]
Re: Web Service Method Can't return a DataTable? Joseph Geretz
2/21/2007 7:27:32 PM
Hi Manish,

I am trying to do as you suggest, however for some reason, the proxy doesn't
seem to generate the proper return type.

Here's the Web Service Method:

[WebMethod]
[SoapHeader("m_Token", Direction = SoapHeaderDirection.InOut)]
public DataTable GetUserProfile()

Here's the line of code I use to call this method:

DataTable DT = (DataTable) m_ServerApp.GetUserProfile();

Here's the error which the compiler throws:

Cannot convert type
'WSAClient.ServerApp.GetUserProfileResponseGetUserProfileResult' to
'System.Data.DataTable'

I don't get it. What sort of return type is
GetUserProfileResponseGetUserProfileResult? (BTW, the cast is irrelevant to
this question, without the cast I get 'cannot implicitly convert yada, yada,
yada'.)

BTW, the fellow here is experiencing the same issue, but I didn't see that
he got an answer.

http://www.thescripts.com/forum/thread430347.html

Anyone have the answer to this problem?

Thanks!

- Joseph Geretz -


[quoted text, click to view]

Re: Web Service Method Can't return a DataTable? Joseph Geretz
2/21/2007 7:42:09 PM
More info:

I went into the proxy and hand coded it to:

public System.Data.DataTable GetUserProfile()
{
object[] results = this.Invoke("GetUserProfile", new object[0]);
return ((System.Data.DataTable)(results[0]));
}

But the next time I refresh the web service, it reverts back to:

public GetUserProfileResponseGetUserProfileResult GetUserProfile()
{
object[] results = this.Invoke("GetUserProfile", new object[0]);
return ((GetUserProfileResponseGetUserProfileResult)(results[0]));
}

If I have to keep handcoding this every time I need to refresh the proxy
with the latest Web Service definitions, then this is a non-starter; I'll
have to go back to using a DataSet, rather than a DataTable.

Any idea what's going wrong here?

Thanks!

- Joseph Geretz -

[quoted text, click to view]

Re: Web Service Method Can't return a DataTable? rolf.stocker NO[at]SPAM gmail.com
3/22/2007 2:29:45 AM
[quoted text, click to view]

Hi Joe,

Did you ever find a solution? I am having the same problem and want to
avoid going to using a DataSet.

Thanks,
Rolf
AddThis Social Bookmark Button