all groups > c# > april 2006 >
You're in the

c#

group:

Adding a Web Reference changes DataTypes ???


RE: Adding a Web Reference changes DataTypes ??? Peter Bromberg [C# MVP]
4/30/2006 11:53:01 AM
c#:
Put the datatable inside a new DataSet and have the WebMethod return a
DataSet object.

I don't believe the WebService infrastructure is capable of intelligently
serializing a datatable by itself.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




[quoted text, click to view]
Re: Adding a Web Reference changes DataTypes ??? Peter Bromberg [C# MVP]
4/30/2006 3:45:01 PM
Ok. The easiest way to figure this out is to look at the SOAP Envelope that's
returned by the WebService. YOu can examine the XML and see (for example) if
it could be loaded into a DataSet object with ReadXml and provide easy access
to the DataTable that way, or it may be that's it's being returned as an
array. if your web proxy class can't represent it accurately on the client
side, then you need to look at the raw XML to figure out what is being
returned to you.

WebService Studio is a nice tool that makes this easy. I think its on
Gotdotnet.com in the user samples or in a workspace.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




[quoted text, click to view]
Adding a Web Reference changes DataTypes ??? cc
4/30/2006 8:41:26 PM
Hi,

I having created a simple WebService (in VS 2005) with just one WebMethod as
follows :
[WebMethod]
public DataTable GetProducts()
{
DataTable objDataTable = null;

// code for filling up the datatable

return objDataTable;
}

Then, Adding the WebService as a Web Reference to a Client Application is
following proxy code generated
at the client for the WebMethod :

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

Look at the return type of the method :
at the server it was defined as DataTable but at the client is it changed to
an unreadable name GetProductsResponseGetProductsResult ???

What is happening here ? how can I make sure that the DataTable-type is used
at the client as well ?

thanks
Chris

Re: Adding a Web Reference changes DataTypes ??? cc
4/30/2006 9:27:48 PM
thanks for the tip !

Still, at my company, they are using a WebMethod that returns something of
type DataTable and the proxy code uses DataTable as well !!!
And I have been asked to use the same webmethod in my client but can't get
it work !!

any idea how the datatable can be maintained ?

thanks
Chris


[quoted text, click to view]

Re: Adding a Web Reference changes DataTypes ??? Cor Ligthert [MVP]
5/1/2006 12:00:00 AM
CC

I would use VB Net that is much simpler for this,

Cor

"cc" <cmrchs@yahoo.com> schreef in bericht
news:4455044f$0$21796$ba620e4c@news.skynet.be...
[quoted text, click to view]

Re: Adding a Web Reference changes DataTypes ??? cc
5/1/2006 12:00:00 AM
thanks Peter !
I'll have a look with the tool you suggest.

Chris

[quoted text, click to view]

AddThis Social Bookmark Button