How to access WCF RIA service from Windows Service?

Posted by Duncan Bayne on Stack Overflow See other posts from Stack Overflow or by Duncan Bayne
Published on 2010-05-09T23:53:17Z Indexed on 2010/05/09 23:58 UTC
Read the original article Hit count: 874

Filed under:
|
|

I have a functioning SL4 application; inside the ClientBin directory I have an .svc file that describes my service:

<% @ServiceHost Service="MyApp.Services.MyServiceFactory="System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory" %>

When I browse to http://localhost:52878/ClientBin/MyApp-Services-MyService.svc I see the following:

"You have created a service. To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: svcutil.exe http://localhost:52878/ClientBin/MyApp-Services-MyService.svc?wsdl"

I want to access that service from a Windows Service application. My understanding is that I need to enable SOAP end-points in order to make this happen. So, I add the following to my web.config file:

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

Firstly, Intellisense complains about the presence of the tag, saying "The element system.ServiceModel has invalid child element domainServices."

Secondly, the aforementioned Silverlight application stops working, presumably because this change breaks the underlying web services.

Thirdly, it appears that the System.ServiceModel.DomainServices.Hosting assembly doesn't actually contain the SoapXmlEndpointFactory type; if I try to browse to the service after adding the above to web.config I see:

"Could not load type 'System.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory' from assembly 'System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."

If I inspect the assembly using Reflector, I see that it contains the DomainServiceEndpointFactory and PoxBinaryEndpointFactory types, but no SoapXmlEndpointFactory. Could someone please let me know what I'm doing wrong? I can't believe that it should be this hard to simply consume a WCF RIA service in something other than a Silverlight application!

Yours, Duncan Bayne

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf-ria-services