Home All Groups Group Topic Archive Search About

Adding a Web Reference changes DataTypes ???

Author
30 Apr 2006 6:41 PM
cc
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

Author
30 Apr 2006 6:53 PM
Peter Bromberg [C# MVP]
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




Show quote
"cc" wrote:

> 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
>
>
>
Author
30 Apr 2006 7:27 PM
cc
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


Show quote
"Peter Bromberg [C# MVP]" <pbromberg@yahoo.nospammin.com> wrote in message
news:13FDA5CB-EAD8-487B-82F0-9BC3CCA9AE6A@microsoft.com...
> 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
>
>
>
>
> "cc" wrote:
>
> > 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
> >
> >
> >
Author
30 Apr 2006 10:45 PM
Peter Bromberg [C# MVP]
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




Show quote
"cc" wrote:

> 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
>
>
> "Peter Bromberg [C# MVP]" <pbromberg@yahoo.nospammin.com> wrote in message
> news:13FDA5CB-EAD8-487B-82F0-9BC3CCA9AE6A@microsoft.com...
> > 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
> >
> >
> >
> >
> > "cc" wrote:
> >
> > > 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
> > >
> > >
> > >
>
>
>
Author
1 May 2006 10:45 AM
cc
thanks Peter !
I'll have a look with the tool you suggest.

Chris

Show quote
"Peter Bromberg [C# MVP]" <pbromberg@yahoo.nospammin.com> wrote in message
news:4E1CBF26-116C-4004-800C-5F1A1B9FB7D9@microsoft.com...
> 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
>
>
>
>
> "cc" wrote:
>
> > 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
> >
> >
> > "Peter Bromberg [C# MVP]" <pbromberg@yahoo.nospammin.com> wrote in
message
> > news:13FDA5CB-EAD8-487B-82F0-9BC3CCA9AE6A@microsoft.com...
> > > 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
> > >
> > >
> > >
> > >
> > > "cc" wrote:
> > >
> > > > 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
> > > >
> > > >
> > > >
> >
> >
> >
Author
1 May 2006 4:35 AM
Cor Ligthert [MVP]
CC

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

Cor

Show quote
"cc" <cmr***@yahoo.com> schreef in bericht
news:4455044f$0$21796$ba620e4c@news.skynet.be...
> 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
>
>
Author
1 May 2006 10:37 PM
Peter Bromberg [C# MVP]
Cor,
With all due respect, and notwithstanding the fact that you are posting to
the C# newsgroup and then advising posters that using VB.NET can solve their
issues better, I fail to see what VB.NET can do for this individual that he
can't do with C#, which is the programming language he has chosen?
Peter

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




Show quote
"Cor Ligthert [MVP]" wrote:

> CC
>
> I would use VB Net that is much simpler for this,
>
> Cor
>
> "cc" <cmr***@yahoo.com> schreef in bericht
> news:4455044f$0$21796$ba620e4c@news.skynet.be...
> > 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
> >
> >
>
>
>
Author
2 May 2006 12:11 AM
William Stacey [MVP]
It was a crosspost, but I agree totally agree Peter.

--
William Stacey [MVP]

Show quote
"Peter Bromberg [C# MVP]" <pbromberg@yahoo.nospammin.com> wrote in message
news:102A1DE8-1A95-4B75-A257-76270FF63E30@microsoft.com...
| Cor,
| With all due respect, and notwithstanding the fact that you are posting to
| the C# newsgroup and then advising posters that using VB.NET can solve
their
| issues better, I fail to see what VB.NET can do for this individual that
he
| can't do with C#, which is the programming language he has chosen?
| Peter
Author
2 May 2006 5:11 AM
Cor Ligthert [MVP]
Peter,

I completely agree with you, I could not resist doing it like this, it was a
trap. However, the OP did not ask "why". If he had done I would have written
than "why do you post than to the language.vb newsgroup"

It was just trying another approach, but the OP did not go into the trap.

:-)

Cor

Show quote
"Peter Bromberg [C# MVP]" <pbromberg@yahoo.nospammin.com> schreef in bericht
news:102A1DE8-1A95-4B75-A257-76270FF63E30@microsoft.com...
> Cor,
> With all due respect, and notwithstanding the fact that you are posting to
> the C# newsgroup and then advising posters that using VB.NET can solve
> their
> issues better, I fail to see what VB.NET can do for this individual that
> he
> can't do with C#, which is the programming language he has chosen?
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> CC
>>
>> I would use VB Net that is much simpler for this,
>>
>> Cor
>>
>> "cc" <cmr***@yahoo.com> schreef in bericht
>> news:4455044f$0$21796$ba620e4c@news.skynet.be...
>> > 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
>> >
>> >
>>
>>
>>
Author
2 May 2006 8:54 AM
Cor Ligthert [MVP]
Peter,

There was something more that I almost forgot.

I wrote in my idea nothing wrong, however I could have placed two words
extra.

"I would use VB Net that is much simpler for this, *for me*".

But I thought that that was obvious because I wrote *I would* .

:-)

Cor

I wrote
Show quote
"Peter Bromberg [C# MVP]" <pbromberg@yahoo.nospammin.com> schreef in bericht
news:102A1DE8-1A95-4B75-A257-76270FF63E30@microsoft.com...
> Cor,
> With all due respect, and notwithstanding the fact that you are posting to
> the C# newsgroup and then advising posters that using VB.NET can solve
> their
> issues better, I fail to see what VB.NET can do for this individual that
> he
> can't do with C#, which is the programming language he has chosen?
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> CC
>>
>> I would use VB Net that is much simpler for this,
>>
>> Cor
>>
>> "cc" <cmr***@yahoo.com> schreef in bericht
>> news:4455044f$0$21796$ba620e4c@news.skynet.be...
>> > 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
>> >
>> >
>>
>>
>>

AddThis Social Bookmark Button