Pick a Silverlight RIA scenario [D2D, B2E, B2B, B2C] or choose a Web Services style [SOAP/RPC, XML/REST]

Limitations when accessing REST services from Silverlight

As explained in What are those SOAP/RPC and XML/REST styles ?, the REST support in Silverlight has several limitations :

  • Only the "Content-Type" HTTP header can be accessed from the Silverlight client code.
  • The WebClient works fine in most scenarios, yet turn to HttpWebRequest if you need to control the response flow.
  • HTTP methods are limited to POST and GET (no PUT, nor DELETE support) - see below
  • You may encounter Browser Caching issues - see below

1. Manipulating a REST service model is done via 4 basic HTTP methods: GET, POST, PUT, DELETE . The last two methods are not yet supported by Silverlight :

image

2. Cache issue

You request data from a REST service by invoking a URI with the WebClient class. As all service communications are async in Silverlight, you process the result through an handler.

   1:  WebClient client = new WebClient();
   2:  client.DownloadStringCompleted += 
   3:  new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
   4:  client.DownloadStringAsync(new Uri(“http://foo.org/service/items”));
 

You may experience that the same data gets always retrieved, even when modified on the service side. To solve this problem :

  • either set the Cache Control with "no-cache" value on the service side,  
  • or ensure that subsequent calls are made with differents URI (so that the results do not get cached). This is mandatory if the REST framework on the service side does not support cache header customization, as it is the case for the Restlet framework (as of July 2008, Jerome Louvel is working on it).
client.DownloadStringAsync(new Uri(“http://foo.org/service/items?cache=" + DateTime.Now)); 
  
- Ronny Kwon
Published 30 July 08 11:35 by Steve SFARTZ
Filed under: ,

Comments

# A Cup of Silverlight, RIA & Interoperability : What are those SOAP/RPC and XML/REST styles ? said on July 30, 2008 5:38 AM:

PingBack from http://blogs.msdn.com/silverlight_plus_java/archive/2008/07/30/what-are-those-soap-rpc-and-xml-rest-styles.aspx

# A Cup of Silverlight, RIA & Interoperability said on July 30, 2008 8:43 AM:

The HowTo series demonstrates Silverlight accessing Web Services in various configurations. In this post,

Anonymous comments are disabled

About Steve SFARTZ

I work for Microsoft France as a Technology Evangelist with expertise in Enterprise Architecture, Interoperability, SOA & Cloud Computing.
Contact me or read one of my other blogs : Think Big mais pas trop..., SOA & Interop @Microsoft France, Cloud Computing @ Microsoft France, Silverlight, RIA & Interoperability

Au sein de l'équipe Entreprise de Microsoft France, je me concentre sur les problématiques Cloud Computing, SOA et Interopérabilité.
Contactez-moi ou bien consultez l'un de mes blogs : Think Big mais pas trop..., SOA & Interop @Microsoft France, Cloud Computing @ Microsoft France, Silverlight, RIA & Interoperability

Search

This Blog

Syndication

Page view tracker