473,385 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Adding a Web Reference changes DataTypes ???

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
Apr 30 '06 #1
9 1473
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

Apr 30 '06 #2
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
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:13**********************************@microsof t.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

Apr 30 '06 #3
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]" <pb*******@yahoo.nospammin.com> wrote in message
news:13**********************************@microsof t.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


Apr 30 '06 #4
CC

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

Cor

"cc" <cm****@yahoo.com> schreef in bericht
news:44***********************@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

May 1 '06 #5
cc
thanks Peter !
I'll have a look with the tool you suggest.

Chris

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:4E**********************************@microsof t.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]" <pb*******@yahoo.nospammin.com> wrote in message news:13**********************************@microsof t.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
>
>
>


May 1 '06 #6
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" <cm****@yahoo.com> schreef in bericht
news:44***********************@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


May 1 '06 #7
It was a crosspost, but I agree totally agree Peter.

--
William Stacey [MVP]

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:10**********************************@microsof t.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
May 2 '06 #8
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

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> schreef in bericht
news:10**********************************@microsof t.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" <cm****@yahoo.com> schreef in bericht
news:44***********************@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
>
>


May 2 '06 #9
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
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> schreef in bericht
news:10**********************************@microsof t.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" <cm****@yahoo.com> schreef in bericht
news:44***********************@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
>
>


May 2 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Riccardo Rossi | last post by:
Hi all! How does Python pass arguments to a function? By value or by reference? Thanks, Riccardo Rossi.
2
by: tdmailbox | last post by:
I have a production application that I am building some upgrades using a second (empty) copy the database. A few of the upgrades included changing the datatypes of a few fields from varchar to...
2
by: sam | last post by:
Hi, I've been buried in xsl and xslt articles for several days now, and am still unsure as to what I need to do... Basically, my vb.net app loads up an XML file from an external source...
2
by: JD | last post by:
I'm trying to add a custom utility.mde reference to an application from code using the standard Application.References.AddFromFile code. IT has worked really well with A2K for a couple of years but...
8
by: Bri | last post by:
Greetings, I am using Eval() in a query with only limited success. If the text within the function contains a reference to a Field I get #ERROR#. I'll try and explain what I'm trying to do and...
7
by: Andy Bates | last post by:
I have hopefully a simple problem in C#. I designed a form with a listview on left, vert splitter against that, then the remainder of the form from top to bottom: a listview, horiz splitter and...
14
by: 97T | last post by:
Well this is still bugging me. I know there are other ways around this, but for a number of reasons I would like to be able to do this one simple thing. I have a form with a number of controls...
1
by: cc | last post by:
Hi, I having created a simple WebService (in VS 2005) with just one WebMethod as follows : public DataTable GetProducts() { DataTable objDataTable = null; // code for filling up the...
7
by: Maximus Decimus | last post by:
HI all, I am using python v2.5 and I am an amateur working on python. I am extending python for my research work and would like some help and guidance w.r.t this matter from you experienced...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.