HighTechTalks DotNet Forums  

returning strongly typed dataset from web service

ASP.net Web Services microsoft.public.dotnet.framework.aspnet.webservices


Discuss returning strongly typed dataset from web service in the ASP.net Web Services forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
N. Shehzad
 
Posts: n/a

Default returning strongly typed dataset from web service - 03-02-2007 , 06:42 PM






All,
I have a webservice webmethod which does returns a strongly typed dataset
called MyStronglyTypedDataSet correctly.

On the client side, when I cast the dataset to my strongly typed dataset, it
throws the following error "Cannot convert type
ClientConsumer.localhost.MyStronglyTypedDataSet" to
"MyNameSpace.WebServices.MyStronglyTypedDataSe t'

If I cast it as a regular dataset on client side, it works fine, but that
defeats the whole purpose of having strongly typed DS in first place.

I am using a web reference from the client application to the web service,
and also reference to the StronglyTpedDataSet dll that I created using SDK
Command Prompt

What am I doing wrong?



Reply With Quote
  #2  
Old   
John Saunders
 
Posts: n/a

Default Re: returning strongly typed dataset from web service - 03-03-2007 , 01:43 PM






"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote

Quote:
All,
I have a webservice webmethod which does returns a strongly typed dataset
called MyStronglyTypedDataSet correctly.

On the client side, when I cast the dataset to my strongly typed dataset,
it
throws the following error "Cannot convert type
ClientConsumer.localhost.MyStronglyTypedDataSet" to
"MyNameSpace.WebServices.MyStronglyTypedDataSe t'

If I cast it as a regular dataset on client side, it works fine, but that
defeats the whole purpose of having strongly typed DS in first place.

I am using a web reference from the client application to the web service,
and also reference to the StronglyTpedDataSet dll that I created using SDK
Command Prompt

What am I doing wrong?
Why are you referencing the dll from the server? The client and server
classes have no direct relation to each other.

What happens if you create a new project and use Add Web Reference to add a
reference to your web service? Isn't that enough to get you your
strongly-typed dataset on the client side?

John

P.S. I just tried it myself, and it seems to work. Just keep in mind that
you've got a server-side DataSet and a client-side proxy DataSet, and that
the two types are unrelated.




Reply With Quote
  #3  
Old   
Scott M.
 
Posts: n/a

Default Re: returning strongly typed dataset from web service - 03-03-2007 , 07:44 PM



Why are you trying to cast an object into the type that it already is? You
don't need to cast at all here.

Your client code should simply be:

Dim receivedDataSet As MyStronglyTypedDataSet = webService.webMethodCall()

If your web method is returing a type of "MyStronglyTypedDataSet", all you
need to do is set up a pointer (not a new instance) to that returned object.
That pionter needs to be declared as being the same type (or a type that
your returned object derives from).

Now, having said all of this. IMHO you shouldn't be returning a platform
specific object from a web service in the first place. That defeats the
purpose of a web service. I would recommend returning the XML
representation of the strongly typed DataSet from your web service, rather
than the object itself. This keeps your application open to the possibility
of needing a heterogenius architecture in the future.



"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote

Quote:
All,
I have a webservice webmethod which does returns a strongly typed dataset
called MyStronglyTypedDataSet correctly.

On the client side, when I cast the dataset to my strongly typed dataset,
it
throws the following error "Cannot convert type
ClientConsumer.localhost.MyStronglyTypedDataSet" to
"MyNameSpace.WebServices.MyStronglyTypedDataSe t'

If I cast it as a regular dataset on client side, it works fine, but that
defeats the whole purpose of having strongly typed DS in first place.

I am using a web reference from the client application to the web service,
and also reference to the StronglyTpedDataSet dll that I created using SDK
Command Prompt

What am I doing wrong?





Reply With Quote
  #4  
Old   
Sundar Narasiman
 
Posts: n/a

Default RE: returning strongly typed dataset from web service - 03-04-2007 , 09:57 PM



N. Shehzad,

The main reason for the problem is that you are bundling the TypedDataset
into an class library (dll). Please do not package the TypedDataset into an
assembly.
If you do that, you will end-up in the namespace conflicts.
Try using the .xsd for TypedDataset at the
Webservice side and the Client Side. I've used .xsd (instead of bundling .xsd
inside assembly), it works. I could able to successfully pass the
TypedDataset back-and-forth between webservice and client.

Please let me know if this helps


--
Thanks & Regards,
Sundar Narasiman


"N. Shehzad" wrote:

Quote:
All,
I have a webservice webmethod which does returns a strongly typed dataset
called MyStronglyTypedDataSet correctly.

On the client side, when I cast the dataset to my strongly typed dataset, it
throws the following error "Cannot convert type
ClientConsumer.localhost.MyStronglyTypedDataSet" to
"MyNameSpace.WebServices.MyStronglyTypedDataSe t'

If I cast it as a regular dataset on client side, it works fine, but that
defeats the whole purpose of having strongly typed DS in first place.

I am using a web reference from the client application to the web service,
and also reference to the StronglyTpedDataSet dll that I created using SDK
Command Prompt

What am I doing wrong?



Reply With Quote
  #5  
Old   
N. Shehzad
 
Posts: n/a

Default RE: returning strongly typed dataset from web service - 03-05-2007 , 10:21 AM




Hi Sundar,
I did create an .xsd schema first, and created a class file for that xsd
schema using
SDK Command prompt. How would I reference that class on the client side if I
do not create a .dll library. Do I need to include that class on the client
project as well?

Thanks



"Sundar Narasiman" wrote:

Quote:
N. Shehzad,

The main reason for the problem is that you are bundling the TypedDataset
into an class library (dll). Please do not package the TypedDataset into an
assembly.
If you do that, you will end-up in the namespace conflicts.
Try using the .xsd for TypedDataset at the
Webservice side and the Client Side. I've used .xsd (instead of bundling .xsd
inside assembly), it works. I could able to successfully pass the
TypedDataset back-and-forth between webservice and client.

Please let me know if this helps


--
Thanks & Regards,
Sundar Narasiman


"N. Shehzad" wrote:

All,
I have a webservice webmethod which does returns a strongly typed dataset
called MyStronglyTypedDataSet correctly.

On the client side, when I cast the dataset to my strongly typed dataset, it
throws the following error "Cannot convert type
ClientConsumer.localhost.MyStronglyTypedDataSet" to
"MyNameSpace.WebServices.MyStronglyTypedDataSe t'

If I cast it as a regular dataset on client side, it works fine, but that
defeats the whole purpose of having strongly typed DS in first place.

I am using a web reference from the client application to the web service,
and also reference to the StronglyTpedDataSet dll that I created using SDK
Command Prompt

What am I doing wrong?



Reply With Quote
  #6  
Old   
John Saunders
 
Posts: n/a

Default Re: returning strongly typed dataset from web service - 03-05-2007 , 01:39 PM



"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi Sundar,
I did create an .xsd schema first, and created a class file for that xsd
schema using
SDK Command prompt. How would I reference that class on the client side if
I
do not create a .dll library. Do I need to include that class on the
client
project as well?
You don't need to do _anything_ to reference the class on the client side.
Simply define your web service to return the strongly-typed dataset. Then
use Add Web Reference in your client application to cause VS.NET to create
the necessary proxy classes. One of those classes will be a client-side
version of the server-side dataset. You will use that class on the client
side.

You will _never_ reference server-side classes on the client side. NEVER.

John




Reply With Quote
  #7  
Old   
N. Shehzad
 
Posts: n/a

Default Re: returning strongly typed dataset from web service - 03-05-2007 , 02:25 PM



John,
The problem is it does not create those client proxy classes for the dataset.
When I add the web reference, it only creates the localhost reference that's
all



"John Saunders" wrote:

Quote:
"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote in message
news:65D9D99F-99A5-47A5-BFAB-3CF4EE2034EC (AT) microsoft (DOT) com...

Hi Sundar,
I did create an .xsd schema first, and created a class file for that xsd
schema using
SDK Command prompt. How would I reference that class on the client side if
I
do not create a .dll library. Do I need to include that class on the
client
project as well?

You don't need to do _anything_ to reference the class on the client side.
Simply define your web service to return the strongly-typed dataset. Then
use Add Web Reference in your client application to cause VS.NET to create
the necessary proxy classes. One of those classes will be a client-side
version of the server-side dataset. You will use that class on the client
side.

You will _never_ reference server-side classes on the client side. NEVER.

John




Reply With Quote
  #8  
Old   
John Saunders
 
Posts: n/a

Default Re: returning strongly typed dataset from web service - 03-05-2007 , 04:08 PM



"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote

Quote:
John,
The problem is it does not create those client proxy classes for the
dataset.
When I add the web reference, it only creates the localhost reference
that's
all
Select the "localhost" reference in Solution Explorer. Turn on "Show All
Files", either by clicking the icon at the top of the Solution Explorer, or
else using Project->Show All Files. This will add a "+" sign in front of
"localhost". Click the plus signs a few times, and you'll find a
Reference.cs (or .vb) file. Open that, and you should see all of the proxy
classes.

OTOH, which version of VS.NET are you using? This may be a VS2005 feature.

John




Reply With Quote
  #9  
Old   
N. Shehzad
 
Posts: n/a

Default Re: returning strongly typed dataset from web service - 03-05-2007 , 04:10 PM



Actually, I got it to work with one dataset, but if my webservice has
multiple typed datasets, they do not show up as proxy xsd when I create or
update the web reference.



"John Saunders" wrote:

Quote:
"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote in message
news:65D9D99F-99A5-47A5-BFAB-3CF4EE2034EC (AT) microsoft (DOT) com...

Hi Sundar,
I did create an .xsd schema first, and created a class file for that xsd
schema using
SDK Command prompt. How would I reference that class on the client side if
I
do not create a .dll library. Do I need to include that class on the
client
project as well?

You don't need to do _anything_ to reference the class on the client side.
Simply define your web service to return the strongly-typed dataset. Then
use Add Web Reference in your client application to cause VS.NET to create
the necessary proxy classes. One of those classes will be a client-side
version of the server-side dataset. You will use that class on the client
side.

You will _never_ reference server-side classes on the client side. NEVER.

John




Reply With Quote
  #10  
Old   
John Saunders
 
Posts: n/a

Default Re: returning strongly typed dataset from web service - 03-05-2007 , 04:26 PM



"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote

Quote:
Actually, I got it to work with one dataset, but if my webservice has
multiple typed datasets, they do not show up as proxy xsd when I create or
update the web reference.
See my other post, and which version of VS.NET are you using?

John




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.