Search code examples
wcf-ria-services

WCF Ria classlibrary in a console


I have a WCF Ria classlibrary (using EF) which is referenced in web project . Then a silverlight app is linked to the Web project and this works perfectly.

Now I am trying to reuse the WCF Ria classlibrary in a console application. I added a refernce to the WCF ria class library from console and try to do operations. But nothing is happening.

Am I doing something wrong? Is the WCF RIA supposed to consume only Silverlight clients?


Solution

  • Finally I figured it out. We can expose WCF ria using SOAP endpoints. In order to do this,

    step 1

    • make changes in the web.config file of the application where we host the ria service.

    ...............
    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
    

    ....................

    <system.serviceModel>
       <domainServices>
         <endpoints>
           <add name="soap"
                type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, 
                      Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, 
                      Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
           ...
         </endpoints>
       </domainServices>
       ...
     </system.serviceModel>
    
    ........
    

    Step2 - Add reference to the dll

    Microsoft.ServiceModel.DomainServices.Hosting on the wcf ria services.This dll is a part of WCF RIA Services toolkit
    

    Now the The service is ready to use . Usually the service will have a URL like this http:// nameofyourserver:port/ClientBin/NameOfYourSolution-Web-NameOfYourDomainService.svc

    step 3 - Add service reference at the client side just like any other WCF service.

    More details on how to use the WCF RIA exposed via SOAP in a non-silverlight app is here http://blogs.msdn.com/b/brada/archive/2010/03/29/silverlight-4-ria-services-ready-for-business-exposing-wcf-wsdl-services.aspx