<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Saurabh Pant's Weblog  : Silverlight</title><link>http://blogs.msdn.com/saurabh/archive/tags/Silverlight/default.aspx</link><description>Tags: Silverlight</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Understanding the WCF in ‘WCF RIA Services’</title><link>http://blogs.msdn.com/saurabh/archive/2009/11/23/understanding-the-wcf-in-wcf-ria-services.aspx</link><pubDate>Tue, 24 Nov 2009 07:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9927754</guid><dc:creator>Saurabh</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/saurabh/comments/9927754.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh/commentrss.aspx?PostID=9927754</wfw:commentRss><description>&lt;P&gt;At PDC 2009 we (RIA Services Team) announced the re-branding of Microsoft .NET RIA Services to &lt;STRONG&gt;Windows Communication Foundation (WCF) RIA Services.&amp;nbsp; &lt;/STRONG&gt;We backed this branding change with a new Preview release, that has RIA Services built heavily on the WCF stack.&lt;/P&gt;
&lt;P&gt;In this post I plan to talk briefly about the motivation behind aligning RIA Services with WCF and then dig deep into how exactly RIA Services consumes WCF.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=3&gt;RIA Services on WCF: Best of both worlds&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Ever since we announced RIA Services at MIX '09, we have heard strong customers feedback that they would like a consolidated services story from Microsoft. Acting on that feedback, over the last few months RIA Services has spent a significant amount of effort aligning closely with WCF. The Data Services team at their end has been working on a similar alignment with WCF as well.&lt;/P&gt;
&lt;P&gt;By centering all our service offerings around WCF we are maximizing developer knowledge transfer and skill reuse, both in the short and the long term.&lt;/P&gt;
&lt;P&gt;For more details on the alignment and the motivation behind it please also check out &lt;A href="http://blogs.msdn.com/endpoint/archive/2009/11/18/the-wcf-services-ecosystem.aspx" mce_href="http://blogs.msdn.com/endpoint/archive/2009/11/18/the-wcf-services-ecosystem.aspx"&gt;this post&lt;/A&gt; by the WCF team. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_thumb.png" width=458 height=345 mce_src="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I strongly believe that with WCF RIA Services our users get the best of both worlds - &lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;They get all the simplicity and productivity of the RIA Services Prescriptive Programming Model and Tooling &lt;/LI&gt;
&lt;LI&gt;And if need be, they can dig deep into our services infrastructure and harness all the power and flexibility that WCF has to offer&amp;nbsp;&lt;STRONG&gt;&lt;FONT size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;&lt;FONT size=3&gt;Understanding RIA Services use of WCF&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To help users better understand how RIA Services uses WCF, in the following section I walkthrough what happens under the covers when a user creates a simple DomainService and then communicated with it.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1. &lt;/STRONG&gt;&lt;STRONG&gt;‘Add new DomainService Class’&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Lets assume an application developer opens up the ‘Add new Domain Service Class’ item template and adds a new Domain Service. &lt;/P&gt;
&lt;P&gt;The item template, besides producing a skeletal Domain Service Class, adds the right assembly references and registers an Http modules in the Web.Config. By default it registers an httpModule for Cassini (for Visual Studio F5 experience) and one for IIS, as shown below.&lt;/P&gt;
&lt;DIV class=csharpcode&gt;
&lt;DIV class=csharpcode&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN class=html&gt;xml&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="1.0"&lt;/SPAN&gt;?&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;configuration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;STRONG&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;httpModules&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE&gt;      &lt;STRONG&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;add&lt;/SPAN&gt; &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="DomainServiceModule"&lt;/SPAN&gt; &lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=attr&gt;&lt;STRONG&gt;type&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&lt;STRONG&gt;="System.Web.Ria.Services.DomainServiceHttpModule, &lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;STRONG&gt;System.Web.Ria"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;STRONG&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;httpModules&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;compilation&lt;/SPAN&gt; &lt;SPAN class=attr&gt;debug&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="true"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;targetFramework&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="4.0"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt; &lt;/PRE&gt;&lt;PRE class=alt&gt;  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.web&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;  &lt;/PRE&gt;&lt;PRE class=alt&gt;  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.webServer&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;validation&lt;/SPAN&gt; &lt;SPAN class=attr&gt;validateIntegratedModeConfiguration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="false"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;modules&lt;/SPAN&gt; &lt;SPAN class=attr&gt;runAllManagedModulesForAllRequests&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="true"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;      &lt;STRONG&gt;&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;add&lt;/SPAN&gt; &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="DomainServiceModule"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;preCondition&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="managedHandler"&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=attr&gt;&lt;STRONG&gt;type&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&lt;STRONG&gt;="System.Web.Ria.Services.DomainServiceHttpModule, &lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;STRONG&gt;System.Web.Ria"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;modules&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;validation&lt;/SPAN&gt; &lt;SPAN class=attr&gt;validateIntegratedModeConfiguration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="false"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;system.webServer&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;





.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; }&lt;/STYLE&gt;
&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;
&lt;STYLE type=text/css&gt;








.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; }&lt;/STYLE&gt;
&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=kwrd&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;







.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; }&lt;/STYLE&gt;

&lt;P&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt; &lt;STRONG&gt;Domain Service Code&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The developer then goes ahead and adds Business logic to his DomainService.The methods exposed via the DomainService can be broken into two broad categories – &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;CRUD operations –&lt;/STRONG&gt; Query, Update, Named Update and Delete operations. These operations follow the RIA Services prescriptive guideline and rely on the RIA Services framework. This is added functionality that RIA Services introduces on top of WCF and is not available to Core WCF Services.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Service Operation/ Invoke&amp;nbsp;Operations&lt;/STRONG&gt; - These are [Invoke] operation in the RIA Services terminology and Service Operations in WCF terminology. These methods are independent of the RIA Services concept of ChangeSet (ChangeSet applies only to the CRUD operations above) and are ‘Online/Direct’ methods that communicate with the Server immediately when invoked.&lt;/P&gt;
&lt;P&gt;Below is the code for the OrganizationService DomainService we use in our canonical &lt;A href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2387" mce_href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=2387"&gt;RIA Services walkthrough&lt;/A&gt;.&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=kwrd&gt;namespace&lt;/SPAN&gt; HRApp.Web&lt;/PRE&gt;&lt;PRE&gt;{&lt;/PRE&gt;&lt;PRE class=alt&gt;    [EnableClientAccess()]&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; OrganizationService : &lt;/PRE&gt;&lt;PRE class=alt&gt;        LinqToEntitiesDomainService&amp;lt;AdventureWorks_DataEntities&amp;gt;&lt;/PRE&gt;&lt;PRE&gt;    {&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=preproc&gt;#region&lt;/SPAN&gt; CRUD    &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; IQueryable&amp;lt;Employee&amp;gt; GetEmployee(){…}        &lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; InsertEmployee(Employee employee) {…}        &lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; UpdateEmployee(Employee currentEmployee) {…}        &lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; DeleteEmployee(Employee employee) {…}&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; IQueryable&amp;lt;Employee&amp;gt; GetSalariedEmployee(){…}&lt;/PRE&gt;&lt;PRE class=alt&gt;        [RequiresAuthentication()]&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; ApproveSabbatical(Employee current) {…}   &lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=preproc&gt;#endregion&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;    &lt;/PRE&gt;&lt;PRE class=alt&gt;       &lt;SPAN class=preproc&gt;#region&lt;/SPAN&gt; ServiceOperations&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; Echo(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; msg) {…}&lt;/PRE&gt;&lt;PRE class=alt&gt;        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; DateTime GetServerDateTime(){…}&lt;/PRE&gt;&lt;PRE&gt;       &lt;SPAN class=preproc&gt;#endregion&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;    }&lt;/PRE&gt;&lt;PRE&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;


.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; }&lt;/STYLE&gt;

&lt;P&gt;&lt;B&gt;3. WCF Channel on Client&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The RIA Services Framework on the Client contains a &lt;EM&gt;WebDomainClient:DomainClient&lt;/EM&gt; whose purpose is to help the SL client communicate with a WCF service represention of the Domain Service. The &lt;EM&gt;WebomainClient &lt;/EM&gt;uses a WCF Client Chanel for this cummunication.&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;Channel is created by using WCF’s ChannelFactory and by passing to it a WCF Service Contract that was generated from the Domain Service (more on the contract creation later). The ChanelFactory creates a WCF client proxy based on the supplied contract. The generated proxy takes care of communication/(de)serialization between Client and Server.&lt;/P&gt;
&lt;P&gt;The RIA Services &lt;EM&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ee707370(VS.91).aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee707370(VS.91).aspx"&gt;DomainContext&lt;/A&gt;&amp;nbsp;&lt;/EM&gt;utilizes the &lt;EM&gt;WebDomainClient &lt;/EM&gt;for Client-Server communication and the context itself is WCF agnostic.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;4. &lt;/B&gt;&lt;B&gt;Dynamic .SVC generation&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;By default DomainServices do not have a physical .SVC file generated for them at Design Time. &lt;/P&gt;
&lt;P&gt;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: &lt;/P&gt;
&lt;P&gt;[SilverlightApplicationBaseURI] + [DomainServiceFullName].svc (With all “&lt;B&gt;.&lt;/B&gt;” replaced by “&lt;B&gt;-&lt;/B&gt;“)&lt;/P&gt;
&lt;P&gt;So HRApp.Web.OrganizationService is exposed as – &lt;A href="http://[ApplicationBaseURI]/HRApp-Web-OrganizationService.svc" mce_href="http://[ApplicationBaseURI]/HRApp-Web-OrganizationService.svc"&gt;http://[ApplicationBaseURI]/HRApp-Web-OrganizationService.svc&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Below is what the dynamically generated svc file looks like for the OrganizationService defined above - &lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&amp;lt;%@ ServiceHost Service=”HRApp.Web.OrganizationService” &lt;/PRE&gt;&lt;PRE&gt;Factory=”System.Web.Ria.DomainServiceHostFactory”&lt;/PRE&gt;&lt;PRE class=alt&gt;%&amp;gt;&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;


.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; }&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;


.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; }&lt;/STYLE&gt;

&lt;DIV class=csharpcode&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;The .SVC refers to the DomainService Type and a ServiceHostFactory. The default RIA Services&amp;nbsp; 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. &lt;/P&gt;
&lt;P&gt;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&amp;nbsp;.XAP is moved around under the hosting Web App Root, the Silverlight App's relative reference to the DomainService is not broken.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;5. &lt;/B&gt;&lt;B&gt;Generating the WCF Contract:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Each WCF service needs to have a &lt;A href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicedescription.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicedescription.aspx"&gt;ServiceDescription&lt;/A&gt; and one or more &lt;A href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.contractdescription.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.contractdescription.aspx"&gt;ContractDescriptions&lt;/A&gt; for it. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx" mce_href="http://msdn.microsoft.com/en-us/library/system.servicemodel.servicehost.aspx"&gt;ServiceHosts&lt;/A&gt; are responsible for extracting descriptions from a service and hosting the service. The standard ServiceHost in WCF produces descriptions based on WCF attributes such as [ServiceContract] and [OperationContract]. In RIA Services we provide a custom ServiceHost which does this based on a RIA Service Attributes and Conventions.&lt;/P&gt;
&lt;P&gt;Here is how DomainService operations are mapped to the WCF Contract:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Query operations – &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Each Query operation shows up as a ServiceOperation in the WCF Contract, but with its signature modified. &lt;/P&gt;
&lt;P&gt;The ServiceHost creates an operation description for each query operation. The return type is changed to QueryResult&amp;lt;T&amp;gt; such that it can return additional information such as count. It also adds a QueryOperationBehavior which through a custom operation Invoker takes care of applying cache policies, validating parameters and composing queries.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Insert, Update, Delete operations – &lt;/B&gt;&lt;/P&gt;
&lt;P&gt;For all CUD operations the ServiceHost generates one top-level SubmitChanges operation description. Again, it adds a custom behavior which injects a custom operation invoker. The signature of SubmitChanges is &lt;EM&gt;ChangeSet SubmitChanges(ChangeSet changeSet)&lt;/EM&gt;. The returned ChangeSet contains auto-generated values from the server.&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Invoke Operations – &lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Invoke Operations are the RIA Services equivalent of WCF ServiceOperations. All Invoke Operations show up in the WCF Contract as Service Operations. &lt;/P&gt;
&lt;P&gt;For the OrganizationService Domain Service we had defined earlier, below is what the WCF Contract looks like to the “Add Service Reference” dialog - &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; WIDTH: 397px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 202px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_thumb_2.png" width=296 height=143 mce_src="http://blogs.msdn.com/blogfiles/saurabh/WindowsLiveWriter/UnderstandingtheWCFinWCFRIAServices_F638/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Attached to this post is also the full generated WCF Contract for the OrganizationService (the file was produced by doing an Add Service Reference to the Domain Service's WCF endpoint)&lt;/P&gt;
&lt;P&gt;&lt;B&gt;6. &lt;/B&gt;&lt;B&gt;Default Endpoints:&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The RIA Services ServiceHost creates the following endpoints by default -&amp;nbsp; &lt;/P&gt;
&lt;P&gt;a) For Silverlight Client: SOAP w/binary endpoint. Address = “binary”, Binding = CustomBinding consisting of HttpTransportBindingElement and BinaryMessageEncodingBindingElement.&lt;/P&gt;
&lt;P&gt;b) For AJAX Client: JSON REST endpoint. Address = “”, Binding = WebHttpBinding w/JSON as the format.&lt;/P&gt;
&lt;P&gt;c) For other clients : SOAP w/XML endpoint. Address = “soap”, Binding = BasicHttpBinding consisting of HttpTransportBindingElement and TextMessageEncodingBindingElement.&lt;/P&gt;
&lt;P&gt;The blog post &lt;A href="http://blogs.msdn.com/brada/archive/2009/11/22/ria-services-a-domainservice-is-a-wcf-service-add-service-reference.aspx" target=_blank mce_href="http://blogs.msdn.com/brada/archive/2009/11/22/ria-services-a-domainservice-is-a-wcf-service-add-service-reference.aspx"&gt;here&lt;/A&gt; describes how one can consume the SOAP XML endpoint in a WindowsForms application. &lt;A href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=3587" target=_blank mce_href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=3587"&gt;Here&lt;/A&gt; is a Sample of the same endpoint being consumed in a WPF application.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=3&gt;Summary&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Above we discussed in some detail how RIA Services uses WCF under the covers. Hopefully this helps folks better understand the RIA Services alignment with WCF.&lt;/P&gt;
&lt;P&gt;In a future post I&amp;nbsp; plan to discuss how WCF extensibility (e.g. custom behaviors) can be applied to Domain Services. In the meanwhile &lt;A href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=3576" target=_blank mce_href="http://code.msdn.microsoft.com/RiaServices/Release/ProjectReleases.aspx?ReleaseId=3576"&gt;here&lt;/A&gt; is a Sample that demos this.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927754" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/saurabh/attachment/9927754.ashx" length="48212" type="text/plain" /><category domain="http://blogs.msdn.com/saurabh/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/saurabh/archive/tags/RIAServices/default.aspx">RIAServices</category></item><item><title>VS Live 2008 Orlando - Silverlight 2 Talk</title><link>http://blogs.msdn.com/saurabh/archive/2008/05/13/vs-live-2008-orlando-silverlight-2-talk.aspx</link><pubDate>Tue, 13 May 2008 19:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8500860</guid><dc:creator>Saurabh</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/saurabh/comments/8500860.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh/commentrss.aspx?PostID=8500860</wfw:commentRss><description>&lt;P&gt;Later today,&amp;nbsp;I present @ &lt;A class="" title="VS Live Orlando 2008" href="http://vslive.com/2008/orlando/" mce_href="http://vslive.com/2008/orlando/"&gt;VS Live&lt;/A&gt; the following talk ...&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;A class="" id=vm12 title=vm12 name=vm12&gt;&lt;/A&gt;Building Rich Internet Application using Microsoft Silverlight 2.0&lt;/STRONG&gt;&lt;BR&gt;In this session, we will build a Video Search Web Site using Silverlight 2.0. The session will demo – how to use Visual Studio to create a Sliverlight applications, how to create UI using XAML markup and code, how to retrieve data from a web service, how to manipulate &amp;nbsp;data with XML and LINQ, how to persist user settings using local storage, how to interact with browser using HTML DOM, how to use the SL OpenFile dialog etc …&lt;/P&gt;
&lt;P&gt;Attached are the Source code/Presentaion/DemoScript for the talk .&lt;/P&gt;
&lt;P&gt;Guthrie’s Silverlight Tips, Tricks, Tutorials and Links Page are available &lt;A class="" href="http://weblogs.asp.net/scottgu/pages/silverlight-posts.aspx" mce_href="http://weblogs.asp.net/scottgu/pages/silverlight-posts.aspx"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The MIX sessions I referred to are available online &lt;A class="" href="http://sessions.visitmix.com/" mce_href="http://sessions.visitmix.com/"&gt;here&lt;/A&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In particular, the talk above was modeled after Joe Stegman and Mike Harsh's&amp;nbsp;&lt;A class="" href="http://sessions.visitmix.com/" mce_href="http://sessions.visitmix.com/"&gt;&lt;FONT color=#006ff7&gt;MIX 08 session&lt;/FONT&gt;&lt;/A&gt; of the same name, the code for which is availabe &lt;A class="" href="http://blogs.msdn.com/mharsh/archive/2008/03/05/slides-and-demos-from-my-mix-08-talk.aspx" mce_href="http://blogs.msdn.com/mharsh/archive/2008/03/05/slides-and-demos-from-my-mix-08-talk.aspx"&gt;&lt;FONT color=#006ff7&gt;here&lt;/FONT&gt;&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;The UX Skin that&amp;nbsp;I demoed was created by Corrina and she has bloged about it &lt;A class="" href="http://blogs.msdn.com/corrinab/archive/2008/03/24/a-new-control-skin-set.aspx" mce_href="http://blogs.msdn.com/corrinab/archive/2008/03/24/a-new-control-skin-set.aspx"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;The page demoing the Silverlight 2 Beta 1 controls is available &lt;A class="" href="http://blogs.msdn.com/kathykam/archive/2008/03/05/silverlight-2-beta-1-control-samples.aspx" mce_href="http://blogs.msdn.com/kathykam/archive/2008/03/05/silverlight-2-beta-1-control-samples.aspx"&gt;here&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;Enjoy !!!&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8500860" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/saurabh/attachment/8500860.ashx" length="3260256" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/saurabh/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Smart Client: Whats new in Orcas?</title><link>http://blogs.msdn.com/saurabh/archive/2007/03/26/smart-client-whats-new-in-orcas.aspx</link><pubDate>Mon, 26 Mar 2007 13:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1951439</guid><dc:creator>Saurabh</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/saurabh/comments/1951439.aspx</comments><wfw:commentRss>http://blogs.msdn.com/saurabh/commentrss.aspx?PostID=1951439</wfw:commentRss><description>&lt;P&gt;Am presenting the following talk at DevConnections today - &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;VMS311:&amp;nbsp;Smart Clients: What's New in Visual Studio "Orcas"?&lt;BR&gt;&lt;/STRONG&gt;&lt;A class="" href="http://blogs.msdn.com/saurabh" mce_href="http://blogs.msdn.com/saurabh"&gt;&lt;STRONG&gt;Saurabh&amp;nbsp;Pant&lt;/STRONG&gt;&lt;/A&gt;&lt;BR&gt;Visual Studio "Orcas" is about making the rapid application development experience even easier. In this overview we will introduce new features that allow Smart Clients to go where they never have before: including Occasionally Connected Systems, SQL Server Compact Edition, Client App Services, N-Tier Data, ClickOnce Deployment enhancements, as well as out-of-the-box ways to future proof your existing applications: including Windows Forms / WPF Integration, and Vista enhancements. Add to that the designer productivity enhancements and see an exciting new wave of smart client development.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were at the session&amp;nbsp;the side deck is attached to this post as promised. &lt;/P&gt;
&lt;P&gt;As always feedback/thoughts are welcome. Feel free to contact me through this blog is you would like additional information on any of the technologies discussed.&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1951439" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/saurabh/attachment/1951439.ashx" length="1154467" type="application/vnd.openxmlformats-officedocument.pres" /><category domain="http://blogs.msdn.com/saurabh/archive/tags/Silverlight/default.aspx">Silverlight</category></item></channel></rss>