If you have developed a solution using WCF RIA and Silverlight and would like to use additional clients such as WPF with your WCF RIA services this article will show you one way it can be done.
Building the Sample
This sample was designed for Visual Studio 2012, .NET 4.5, Silverlight 5 SDK, WCF RIA 1.0 SP2 SDK, and WCF RIA Services Toolkit (September 2011).
This sample is based on the MSDN Walkthrough: How to: Create a Domain Service that uses POCO-defined Entities
WCF RIA has functionality to generate custom clients (DomainContexts) in Silverlight projects that does not mean it is impossible for other types of clients to use the Web Services created by the WCF RIA Services project.
WCF RIA Services generates WCF web services, which can be accessed by non-Silverlight clients.
Here is how you can access your WCF RIA web service from WPF.
Step 1: Expose a SOAP endpoint to your WCF RIA web service
1. In the web project that hosts the DomainService add a reference to Microsoft.ServiceModel.DomainServices.Hosting.dll from the WCF RIA Services normally located in
C:\Program Files (x86)\Microsoft SDKs\RIA Services\v1.0\Toolkit\Libraries\Server\SP2\
2. Update the Web.Config (WCFRIAPOCO.Web\Web.config) to specify a SOAP endpoint for your WCF RIA service.
2.1 Add the XML below to the <System.serviceModel> section.
<!--Add the Soap endpoint from the WCF RIA toolkit (seperate download)-->
<!--You'll need to add a reference to "C:\Program Files (x86)\Microsoft SDKs\RIA Services\v1.0\Toolkit\Libraries\Server\SP2\Microsoft.ServiceModel.DomainServices.Hosting.dll" for this to work-->
name="Soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory,Microsoft.ServiceModel.DomainServices.Hosting, Version=18.104.22.168, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
2.2 If it is missing, add the XML below to the <configuration> section.
name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowDefinition="MachineToApplication" requirePermission="false"
Step 2: Access the WCF RIA service as a WCF web service from WPF
1. Add a ServiceReference to the WCF RIA service.
Make sure the Web project is running, or this won't work (run the web project without debugging, or publush it to your web server).
The web service will be in the following format (YourWebSite/YourRiaProjectName-Web-YourDomainServiceName.svc where "." are replaced by "-")
In the case of the sample the address is
Step 3. Using the WCF SoapClient
to access WCF RIA DomainService ...
1. Access the WCF RIA web service as you would any WCF web service. see WPFClient\MainPage.xa...
MainWindow : Window
//Create an instance of the WCF RIA generated web service SOAP client
SovereignDomainServiceSoapClient _sovereignContext =
//Query the WCF RIA Webservice to get a List of Sovereigns whos reign ends by 1500 and assign i...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.