When you create a WCF RIA Service using VS.NET 2010 we can easily enable OData endpoint as well. This can be done just clicking Check-Box. First let see in Action. First create a silverlight application and do not forgot to check Enable WCF RIA Service Check-Box as shown below.
Next we need to add/Create Model which will expose via WCF-RIA Services. We can create Model using EF or LINQ to SQL . Once you create the model just compile the project so that VS.NET IDE knows the changes we made to our project. (This compilation needed to show Entity when we create RIA services ).
Next step is to Add Domain Data Service template to our project so that we can create WCF RIA Services .
If you see the below dialog box we have an options to check and expose the OData Endpoint.
When you check the Expose OData endpoint Check-Box the following changes were made to your project.(Web Project).
1) The following OData endpoint added to your web.config file
2) Next on each paramaterless query methods marked [Query[IsDefault=true)] attribute
That is it now compile the project and browse the endpoints from IE. Here WCF RIA Services are created @ runtime you do not find .SVC file ( it is created by virtual provider). To access WCF RIA SERVICE and OData Endpoint here is the URL format which we need to construct .
http://ServerName:portnumber/Projectname-DomainService.svc. in my case i am running @ local machine so the WCF RIA SERVICE Endpoint is
http://localhost:61411/ExposeOdataWebApplication-AWDomainService.svc
and OData Endpoint is http://localhost:61411/ExposeOdataWebApplication-AWDomainService.svc/OData/
if you browse http://localhost:61411/ExposeOdataWebApplication-AWDomainService.svc/OData/ProductCategorySet
Nandri(Thanks)
SreenivasaRagavan.
No comments:
Post a Comment