Typed dataset used by two webservices problem

S

Simon Storr

I have two webservices, for arguments sake FredWS and JimWS. They both
contain webmethods which have a typed dataset JoeDataset as a parameter. If
I add a web reference to FredWS (called FredWSProxy) then a class named
FredWSProxy.JoeDataset will be created mapping to JoeDataset (similarly
JimWSProxy.JoeDataset for a web reference to JimWS).

Now in my web app I have a function which calls FredWS returning a
FredWSProxy.JoeDataset. The problem arises when I want to pass this dataset
to JimWSProxy - I can't due to an invalid typecast! Is there a way around
this or do I really have to move all my code into one big webservice?

Also the code generated by the typed dataset xsd generator is huge - is
there any way to 'turn off' sections of code that we don't use from being
generated (all the async stuff for instance?)

Thanks in advance,

Simon
 
R

richlm

One approach I have seen is not to pass dataset directly, but wrap it in an
XML document
e.g.
[WebMethod]
public XmlDocument GetJoeDataset()
{
return new XmlDataDocument(_JoeDataset);
}

You'll still have to do the work of type checking against a XML schema - we
have moved from compile-time-type-checking to run-time-type-checking.
If you have an .xsd you can still re-create a dataset at the client, if
that's what you need.
Here's a couple of articles that discuss this approach:
http://msdn.microsoft.com/msdnmag/issues/03/04/XMLFiles/default.aspx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service02112003.asp

It is not just the proxy code that is huge - the serialized message can be
pretty big too - which the above approach does not solve.

Another "idea" (quick & dirty solution...) could be to use Dataset.Merge to
perform the type conversion. Of course this is a deep copy - but then so is
serializing across the wire, so if you can accept the overhead perhaps this
might work for you.

I prefer to think of web services as a message-based protocol more than a
RPC-type protocol - and therefore serialized XML (which I control) often
fits more naturally than complex types (especially ones native to .NET).
That's just my opinion - there are of course many viewpoints on this.

Hope this helps.
Richard.
 
Y

Yan-Hong Huang[MSFT]

Hello Simon,

Do you have any more concerns on Richard's suggestion? Please feel free to
post here if there is any more questions.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top