tags:

views:

1931

answers:

5

My colleague has found himself in an "interesting" situation. He is working on a Silverlight (2.0) prototype that needs to call existing web services in the enterprise and bind the returned data to data-display controls. The thing is, the web services return .NET DataSets (they are not about to change existing implementations) and Silverlight does not natively support DataSets.

What would a good workaround be? I was thinking an adapter pattern but do not know if middle-man web services to carry out transformations would be a very good idea. Could be tedious if there are many existing web services.

A: 

The dangers and general nastyness of Datasets eh. I would use a generic proxy that is responsible for consuming the webmethod and transforming the dataset into xml/json

redsquare
+1  A: 

AFAIK, when a .NET web service returns a DataSet, it returns its XML representation (which is pretty friendly). The fact that a .NET client can consume the DataSet directly only abstracts the fact that an Xml Serialization-Deserialization is taking place.

So I would manually query the web services you require, observe the generated XML, and then parse it in the client side.

Another possibility is to take advantage of the fact that Web Services use the standard XML Serializer, so you could create the C# classes from the returned schema and then let the XmlSerializer automatically handle it. I'm not sure if the code generated by the XSD.exe tool will be Silverlight friendly, but it is worth giving it a shot.

Santiago Palladino
we have seen the raw XML for DataSets before, and it ain't.... pretty.... In fact, it is downright scary X-)
icelava
The schema part at the beginning may look scary, but if you ommit it and go straight for the data, it may be parsed by an XmlReader, as long as the dataset isnt too complex.http://www.diranieh.com/NETSerialization/XMLSerialization.htm
Santiago Palladino
The general opinion from multiple people is this same approach. Although that would mean slowly drawing the "useful" bits from each type of DataSet XML.
icelava
A: 

The team over at www.silverlightds.com have come up with a complete solution for calling webservices. You can implement your own crud calls or use their helpers, it's quite slick.

vince
A: 

Yup, silverlight ds is a great solution, they even have relationships built into it

+1  A: 

Try the following: http://silverlightdataset.net Best Regards Vitaly

Vitaly