2 Web Services and a Typed DataSet


P

pikachusalad

I am using Visual Studio 2005 Professional.

I have one web service (DataRequester) that would like to get a strongly
typed dataset from another web service (DataRetriever).

The strongly typed dataset (TheDataSet) comes from a class library
(TheLibrary), both web services have a reference to the TheLibrary.dll, and
can use the TheLibrary.TheDataSet just fine.

DataRetriever is able to fetch the data from the DB and put it into a nice
TheLibrary.TheDataSet, and then returns it from a WebMethod
(GetATheDataSet()), whose return type is TheLibrary.TheDataSet.

DataRequester has a Web Reference to DataRetriever, and has code like this:

WebReference.DataRetriever dataRetriever = new WebReference.DataRetriever();
TheLibrary.TheDataSet theDataSet = dataRetriever.GetATheDataSet();

I get the error, when trying to build:

Cannot implicitly convert type WebReference.TheDataSet to
TheLibrary.TheDataSet

Please, someone tell me there is a solution for this? The problem seems to
be that when I create the WebReference, I get a TheDataSet.xsd, and it
apparently doesn't understand that DataRetriever is returning a type that it
already knows about!
 
Ad

Advertisements

J

John Saunders

pikachusalad said:
I am using Visual Studio 2005 Professional.

I have one web service (DataRequester) that would like to get a strongly
typed dataset from another web service (DataRetriever).

The strongly typed dataset (TheDataSet) comes from a class library
(TheLibrary), both web services have a reference to the TheLibrary.dll,
and
can use the TheLibrary.TheDataSet just fine.

DataRetriever is able to fetch the data from the DB and put it into a nice
TheLibrary.TheDataSet, and then returns it from a WebMethod
(GetATheDataSet()), whose return type is TheLibrary.TheDataSet.

DataRequester has a Web Reference to DataRetriever, and has code like
this:

WebReference.DataRetriever dataRetriever = new
WebReference.DataRetriever();
TheLibrary.TheDataSet theDataSet = dataRetriever.GetATheDataSet();

I get the error, when trying to build:

Cannot implicitly convert type WebReference.TheDataSet to
TheLibrary.TheDataSet

Please, someone tell me there is a solution for this? The problem seems
to
be that when I create the WebReference, I get a TheDataSet.xsd, and it
apparently doesn't understand that DataRetriever is returning a type that
it
already knows about!


But it's not the same type!

Web services are loosely-coupled. The client only knows about the server
through the WSDL file, not through the client knowing about the types
exposed by the server by looking at a server assembly.

What's happening is that the client is using a type generated from the
schema in the WSDL file, and that schema is generated from the type on the
server; but the two types have nothing else to do with each other!

If you want the client to know the intimate details of the server, you
should use .NET Remoting instead of web services.

John
 
M

Matt

You can control how the proxy classes get generated with the
SchemaImporterExtension class (new in 2.0). The library or website
that consumes the web service needs a reference to TheLibrary. Using
the Schema Importer Extension (that you implement) you tell .NET not to
generate proxy classes but to use the classes from the library. This
article explains exactly how to do it and it isn't hard at all.

Customizing generated Web Service proxies in Visual Studio 2005
http://www.microsoft.com/belux/msdn/nl/community/columns/jdruyts/wsproxy.mspx
 
J

John Saunders

Matt said:
You can control how the proxy classes get generated with the
SchemaImporterExtension class (new in 2.0). The library or website
that consumes the web service needs a reference to TheLibrary. Using
the Schema Importer Extension (that you implement) you tell .NET not to
generate proxy classes but to use the classes from the library. This
article explains exactly how to do it and it isn't hard at all.

The article is about .NET. If you're creating a web service to be consumed
only by .NET clients, then the article is fine. Otherwise, stay away from
SchemaImporterExtension!

BTW, if your web service is only for .NET clients, then you should consider
using .NET Remoting, which is much more powerful, and performs much better.

John
 
Ad

Advertisements

M

Matt

The Schema Importer Extension has no effect on clients that aren't
..NET. It is only invoked by the consumer, and only if it is directed
to do so by the .config section. My web service is consumed by a PHP
site as well as .NET. For the PHP site it behaves as it always has.
The Schema Importer Extension is harmless: you're just dictating that
the proxy classes are the same type as the objects on the server. It
has no effect on the web service itself and doesn't impact the
compatibility with non-.NET consumers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top