When they officially released the Silverlight RIA Services, I think they made also a smart move: they changed the name in WCF RIA Services. Why smart? ‘Cause I think this should help people to remember that after all, under the hood, we’ll always find our big friend: the Windows Communication Foundation (WCF for friends. 😉
So, keeping this in mind, there are no reasons why the services can be only reached by my Silverlight Client application (ok, I have all the proxy code generation and all the other stuff for free, but… I don’t care 😀 ). And with a little trick we can allow the RIA Services to expose data with OData, SOAP and JSON format, allowing to be reached from any kind of client (from WinPhone 7, to a java client).
To achieve this we need to add a reference to an assembly and add three rows in our config file.
In our RIA Services project we need to add a reference to the Microsoft.ServiceModel.DomainServices.Hosting assembly (from the WCF RIA Serivces Toolkit) and, in the web.config, the <system.serviceModel> section should look like this:
Now to call our services we need only to navigate to the right address that we’ll compose in this way:
http://<host web address>/<services dir>/[namespace]-[typespace]-[classname].svc
where Services is the directory where I’m hosting all the RIA Services, and BusinessApplication1.Web.DomainService1 is the complete typename of our web service class, where we simply substituted the . (dot) with the –.
And.. that’s all, folks!!!