I\'m trying to get a Server application to expose some status information using WCF. In particular I\'m after using WCF services with RESTful \"API\". I\'m hitting somewhat of a
You are missing Spring.Rest : http://springframework.net/index.html#spring-rest-1.0.0-released
I recently ran into the same problem and decided to create a class that has a simplified REST client interface for Silverlight, more or less like WebChannelFactory. Has synchronous-like behavior also.
http://regular-language.blogspot.com/2011/06/wcf-webhttp-rest-client-for-silverlight.html
If this is a simple Xml REST service, why not use the WebClient in Silverlight to capture the XML using Linq to XML? I know you said its messy, but it all depends on how you look at it. if you change your service interface at anytime you're going to have to update your code in multiple places. Thats just the way it is.
So to do this, you will need to capture the data in an async fashion from the WebClient and then parse it with LINQ to XML.
Time Heuer has a good example on his site: http://timheuer.com/blog/archive/2008/03/14/calling-web-services-with-silverlight-2.aspx
Essentially, it looks like this:
WebClient rest = new WebClient();
rest.DownloadStringCompleted += new DownloadStringCompletedEventHandler(rest_DownloadStringCompleted);
rest.DownloadStringAsync(new Uri("http://example.org/current-status/xml"));
Then in your "rest_DownloadStringCompleted" you'd parse the string as XML. Like so:
string data = e.Result;
string url = string.Empty;
XDocument doc = XDocument.Parse(e.Result);
var myResults = from results in doc.Descendants("myXmlElement") ... blah blah blah
I've done the same thing with home grown REST Services from WCF and Silverlight and it worked great.
I almost hate to suggest it but would you feel comfortable with reimplementing the WebChannelFactory<T> class?
From a cursory glance through the Silverlight API it looks like you won't get much help from Microsoft out of the box. You'd need to reimplement a channel class and a factory for it.
Perhaps another way to create the channel and to isolate yourself from the platform-specific code is to create a custom implementation of it? Specifically what I mean is, you create yet another factory class, and the factory class either calls to the WebChannelFactory when it's available, or goes through the hoops of setting it up for you.
Sorry I don't have a more in-depth suggestion. :)
So far I have found a few alternatives to WebChannelFactory for consuming REST services in Silverlight. They have all seen praise in forums and blogs, but I have yet to try any of them myself. I believe all three use generics to easily deserialize request responses into CLR objects.
I am leaning towards RestSharp, because its examples look both simple and extensible to me.