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
  #11  
Old   
N. Shehzad
 
Posts: n/a

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






I am using vs 2005. It seems like vs 2005 only creates proxy xsd class for
only one strongly typed dataset. if the webservice is using multiple
datasets, it does not create multiple classes how can I make the reference
map to reflect both classes?



"John Saunders" wrote:

Quote:
"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote in message
news:B4DCE955-F2E5-4BEE-98E5-DC13E6DDF717 (AT) microsoft (DOT) com...
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
  #12  
Old   
John Saunders
 
Posts: n/a

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






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

Quote:
I am using vs 2005. It seems like vs 2005 only creates proxy xsd class for
only one strongly typed dataset. if the webservice is using multiple
datasets, it does not create multiple classes how can I make the reference
map to reflect both classes?
Are both datasets used as return values?

As an experiment, try changing the return type of the method whose dataset
is being created in the proxy class with one of those that is not:

Now a proxy for class A is being created:

[WebMethod]
A Method1(){return new A();}

[WebMethod]
B Method2(){return new B();}


Change it to this and see what happens:

[WebMethod]
B Method1(){return new B();}

[WebMethod]
A Method2(){return new A();}

John




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

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



This is completely incorrect.

A Typed DataSet is NOT an XSD. These are two different things.

A Typed DataSet is a class that inherits from the DataSet class and has
custom properties and methods created for it that model your specific data.
This is a class and there is NO POSSIBLE WAY to not have it be part of an
assembly (or a namespace for that matter).

An XSD is an XML Schema Document, which is simply an XML Schema model of
your empty DataSet.

I have already provided the source and solution of your problem in my first
reply.



"Sundar Narasiman" <SundarNarasiman (AT) discussions (DOT) microsoft.com> wrote in
message news:2F391621-3DD9-4D6B-B0A4-06365F246976 (AT) microsoft (DOT) com...
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
  #14  
Old   
Scott M.
 
Posts: n/a

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



This is not correct.

When you reference a web service, a proxy class for the web service is
created on the web service consumer. BUT, proxies for all possible
webMethod return types are NOT created.

If the client will be receiving a strongly-typed DataSet, then the client
will need this class referenced directly. This can be accomplished by the
strongly-typed DataSet existing in a separate assembly that both the web
service and it's consumer can both reference separately, or a copy of the
class exists in another place for the client to reference.




"John Saunders" <john.saunders at trizetto.com> 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
  #15  
Old   
Scott M.
 
Posts: n/a

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



No John, only the web service class gets a proxy created for it. Not the
return types of the web method calls.


"John Saunders" <john.saunders at trizetto.com> wrote

Quote:
"N. Shehzad" <NShehzad (AT) discussions (DOT) microsoft.com> wrote in message
news:94B17407-1DCC-4937-BBD5-975380BBC72D (AT) microsoft (DOT) com...
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
  #16  
Old   
Scott M.
 
Posts: n/a

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



XSD's can't be proxies as XSD's aren't classes. You are confusing Schemas
with typed dataSets.


"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.



"John Saunders" wrote:

"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
  #17  
Old   
John Saunders
 
Posts: n/a

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



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote

Quote:
This is not correct.

When you reference a web service, a proxy class for the web service is
created on the web service consumer. BUT, proxies for all possible
webMethod return types are NOT created.

If the client will be receiving a strongly-typed DataSet, then the client
will need this class referenced directly. This can be accomplished by the
strongly-typed DataSet existing in a separate assembly that both the web
service and it's consumer can both reference separately, or a copy of the
class exists in another place for the client to reference.

Sorry, I don't know where you get this from. Maybe you're talking about .NET
1.1?

Of course proxies are created for the WebMethod return types. How do you
expect a client to be able to access them?

I think you're confusing Web Services and Remoting. In the case of Remoting,
you_do_ share the data types.

John




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

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



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote

Quote:
No John, only the web service class gets a proxy created for it. Not the
return types of the web method calls.
Sorry, man, you need to go check your facts. Create an example and see what
happens. I did, and it behaves as I posted.

My only question (which I'll check when I get a chance) is what happens when
there's more than one typed dataset involved. One of the posters said that
only one proxy is generated, and since my example only used one typed
dataset, I can't tell if he's correct or not.

John




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

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



"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote

Quote:
XSD's can't be proxies as XSD's aren't classes. You are confusing Schemas
with typed dataSets.
Scott, have you noticed any .xsd files associated with strongly-typed
DataSets? Do you have strongly-typed datasets in your projects which do NOT
have an .XSD file nearby?

John




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

Default Re: returning strongly typed dataset from web service - 03-06-2007 , 07:32 AM



They are related, but they are not one in the same. Have you noticed that
you can delete either the typed dataset or the XSD and continue to use
whichever remains?

XSD's are not a MS invention, they are the W3C standard schema mechanism. A
typed DataSet is a .NET class that is modeled after your data structure, an
XSD is an XML Schema that is modeled after your data.

They can work together, but they are not the same thing. An XSD is not
defined in the .NET Framework. A DataSet is. An XSD is not a class (and so
you can't have a proxy class for something that isn't a class in the first
place), a typed DataSet is.

"John Saunders" <john.saunders at trizetto.com> wrote

Quote:
"Scott M." <s-mar (AT) nospam (DOT) nospam> wrote in message
news:%23M4AxZ5XHHA.992 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
XSD's can't be proxies as XSD's aren't classes. You are confusing
Schemas with typed dataSets.

Scott, have you noticed any .xsd files associated with strongly-typed
DataSets? Do you have strongly-typed datasets in your projects which do
NOT have an .XSD file nearby?

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.