I recently recorded a Silverlight TV episode where I demoed configuring a RIA Services DomainService to expose SOAP, JSon and OData endpoints. The video went online earlier today and it can be found here.
Oh and be sure to check out for Silverlight TV Episode 28. It’s going to be awesome!! Stay Tuned!
As you all are aware, RIA Services has a great story OM and tooling story for Silverlight.What if you want a mobile application talking to a domain service or an Ajax application? There could be various different reasons why one would want to expose a different endpoint. The great thing is that enabling these endpoints requires minimal changes in your application.
You will need the following components:-
The OData endpoint support is provided out of the box for you. Here is how you can expose an OData Endpoint.
2: public IQueryable<Book> GetBooks()
4: return this.ObjectContext.Books.OrderBy(b => b.Title);
2: <sectionGroup name="system.serviceModel">
3: <section name="domainServices"
6: Version=18.104.22.168, Culture=neutral,
9: requirePermission="false" />
3: <add name="OData"
4: type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
NOTE: The ODATA endpoint has very limited support in V1. There is no Update or LINQ query support in this release.
In my earlier post, I had showed how to configure a domain service for a Windows Phone 7 application. In that post I had used the Soap endpoint. Configuring a soap and JSON endpoint needs the RIA Services toolkit. After you have installed the toolkit, you will need to do the following:-
4: <add name="OData"
5: type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
7: <add name="soap"
8: type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
10: <add name="JSON"
11: type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
Note: You can use SOAP and Json endpoints to submit.
A domain service is a WCF Service; therefore it has a SVC path. You can now access the three endpoint we exposed using that.
The uri for these endpoints are:-
With these exposed endpoints, you can talk to multiple clients. In the episode above, I used the following clients:-
You can download the source code for the demo from here.
Error 1 The "CreateRiaClientFilesTask" task failed unexpectedly.
System.Web.HttpException (0x80004005): Could not load file or assembly 'Microsoft.Web.DomainServices.WebControls, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified.
In the SilverlightStore.Web project, from the References folder removeMicrosoft.Web.DomainServices.WebControls. This reference points to the Microsoft.Web.DomainServices.WebControls.dll file in the Lib folder. Add a reference to Microsoft.Web.DomainServices.WebControls found in the c:\program files\microsoft sdks\... on local machine
This is great, thanks... can you tell me how I then configure all the DataServiceConfiguration properties that I normally would in DateService<T>.InitializeService when using oData in the 'normal' way?
This is fantastic stuff guys. Keep up the good work on the toolkit. Thank you very much for adding the Json endpoint factory, it's turned out to be the best part of RIA for me.
I had installed all the latest updates required for OData,SOAP, JSON endpoints. But when i run the sample application for odata, i am getting an Error Stating
"Service Endpoint Not Fount". Can you please let me know what could be reason for this?
Note: I tried running another sample application from net that expose odata endpoint, it was able to show me the atompub. The same when i tried executing all the steps, i am shown "Endpoint not found"
@Dhinesh - do you have the RIA Services Toolkit installed?
The demo source code's web.config has an invalid element.
I get a squigly under <domainServices> with the tooltip:
The element 'system.serviceModel' has invalid child element 'domainServices'.
I just installed the April 2010 RIA Services Toolkit.
I have a reference to System.ServiceModel.DomainServices.Hosting in my web project.
I have the section group as above.
Has the system.serviceModel changes recently?
If yes, what would be the correct elements to add a soap endpoint?
Is there a way to use soap or json end points together with the authentication services provided by ria services?
I have a winforms app which I want to connect to my domain service using the authentication I have already set up in my RIA services project.
I am wondering whether there is a good way to use Client Application Services? Unfortunately I cannot find any documentation about this.
@Ron - did you manage to fix this problem? I'm having the same issue.
Hi jasonxz, any is idea for this problem?
Ron, Jasonxz, Ingphillip,
I'm getting the same error. find a solution to this?
I've got the dll referenced, the configSection correct, but it simply won't validate the domainServices element. >:
you also need a reference to:
c:\Program Files\Microsoft SDKs\RIA Services\v1.0\Libraries\Server\System.ServiceModel.DomainServices.Server.dll
be advised that the *.DomainServices.Hosting.dll that you need to reference is in the \v1.0\TOOLKIT\Libraries\ folder. (in case you see the non-toolkit version and think you've got it referenced already)
In another post you talked about WCF webservices and performance in Silverlight 3
suggesting that binary encoding over http was a good bet.
Could you show us the custom binding - all the configuration- for RIA and WP7 using basicHTTP, SOAP and binary encoding? - WP7 needs all the performance it can get
This is good stuff.. But could you also talk about authentication, roles and profiles to make it seamless in other clients including Windows Phone with RIA Services. Is there a resource for it yet?
My posts series talk about opening a RIA Services layer to other types of clients (WP7, WPF, HTML5): blogs.msdn.com/.../how-to-open-a-wcf-ria-services-application-to-other-type-of-clients-review-of-the-initial-application-1-5.aspx
It also covers the authentication part.