RIA Services

Topics: Writing modules
Nov 22, 2011 at 9:11 PM
Edited Nov 22, 2011 at 9:14 PM

Hello,

I try to implement a simple RIA Services by following the steps of this tutorial:

http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2010/07/02/silverlight-and-wcf-ria-services-5-authentication.aspx

I started from scratch to Required Authentication, so I tried the simplest RIA Services implementation.

My RIA server is Orchard.Web: that was the only way to get myDomainContext generated code, inside a module the code is not generated !

But the big problem is when I try to use the service : I get a 404 error (not found).

My client is Silverlight and tries to post: /OrchardLocal/Media/Default/Silverlight/RIAServices-Web-DomainServices-MyDomainService.svc/binary/Add

without success.

I can run the same code with a classic MVC3 website without problem, but Orchard seems to run in a different way and can't find any documentation to implement RIA Services.

Thanks in advance for your help.

Coordinator
Nov 22, 2011 at 10:32 PM

The svc extension is probably not wired in web.config.

Nov 23, 2011 at 1:29 PM

RIA Services use Dynamic .SVC generation

By default DomainServices do not have a physical .SVC file generated for them at Design Time.

However each DomainService has a virtual .SVC associated with it. The .SVC represents the WCF Service that services requests for that particular DomainService. For a given DomainService the path to its .SVC can be determined using the following convention:

[SilverlightApplicationBaseURI] + [DomainServiceFullName].svc (With all “.” replaced by “-“)

So HRApp.Web.OrganizationService is exposed as – http://[ApplicationBaseURI]/HRApp-Web-OrganizationService.svc

At RunTime when the first request (within a particular Application Domain) is made for a DomainService's .SVC file , the registered httpModules intercept the call and RIA Services writes out an in memory .SVC file on the fly.

Below is what the dynamically generated svc file looks like for the OrganizationService defined above -

<%@ ServiceHost Service=”HRApp.Web.OrganizationService” 
Factory=”

System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory

%>
<!-- .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } --><!-- .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } -->

The .SVC refers to the DomainService Type and a ServiceHostFactory. The default RIA Services HostFactory instantiates the default RIA Services ServiceHost, which in turn is responsible for extracting the WCF Service Contract from the DomainService (See the ‘Generating a WCF Contract’ paragraph below for more details) and also for hosting the service.

A request for the DomainService .SVC in any folder under the Web Application root is redirected to [WebAppRoot]/Services/[DomainService].svc using ASP.net URL rewriting. The service is thus accessible under any folder in the WebApp. Hence even if a .XAP is moved around under the hosting Web App Root, the Silverlight App's relative reference to the DomainService is not broken.

NOTE - If a physical .svc file with the right file name (as per convention) is present in the ~/Services folder, that is used to define the Service Contract and no virtual .SVC file is generated

This article said, so I try to add routing like this without success:

public IEnumerable<RouteDescriptor> GetRoutes()
 { return new[] { new RouteDescriptor { Priority = 10, Route = new ServiceRoute( "Services/Test/", new System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory(), typeof(RIAServices.Web.DomainServices.MyDomainService)) } }; }

 

Nov 23, 2011 at 1:31 PM

I found that RIA Services were asked since 03/20/2011 in a previous post and from now, nobody seems to be able to implement this feature in Orchard module.

When could we find a tutorial ?

Nov 23, 2011 at 2:30 PM

If someone has time:

- download a new Orchard project, run and setup

- install Silverlight module from gallery

- add a new project Silverlight BusinessApplication to the Orchard solution including a new website to test

- the new silverlight app is linked to the new site via RIA Services

- in Silverlight project, link the app RIA Services to Orchard.Web

- in Orchard.Web project property page -> Silverlight,add the silverlight app to the path : Media/Default/Silverlight/ instead of clientbin and enable RIA Services

- the client Silverlight is ready.

Now, try to plug the RIA Services from the RIA Services website to the Orchard.Web module.

Just build and add a new silverlight page in Dashboard to test.

The goal is if I'm logged in with Orchard, I want Silverlight BusinessApplication to display the user as we can do in a classic MVC3 website. Or sign in using Orchard authentication with Silverlight BusinessApplication.

Coordinator
Nov 23, 2011 at 5:30 PM

> When could we find a tutorial ?

When somebody writes it ;)

Hey, that could be you. The lack of answer seems to indicate that nobody has done this before.