I have a functioning Silverlight 4 application (VS2010, SL4, WCF RIA, hosted on my dev box using Cassini, 64-bit Windows 7). Inside the ClientBin directory I have an .svc file that describes my service:
<% @ServiceHost Service="MyApp.Services.MyService
Factory="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 how I should be doing this? I can't believe that it should be this hard to simply consume a WCF RIA service in something other than a Silverlight application!
Instead of ...
System.ServiceModel.DomainServices.Hosting
use the assembly ...
Microsoft.ServiceModel.DomainServices.Hosting
from the WCF RIA Services toolkit. It contains the type SoapXmlEndpointFactory
.
The default location is ... %Program Files%\Microsoft SDKs\RIA Services\v1.0\Toolkit\Libraries\Server
Have you tried just executing
svcutil.exe http://localhost:52878/ClientBin/MyApp-Services-MyService.svc?wsdl
Alternatively, have you installed the RIA Services toolkit? http://www.microsoft.com/downloads/details.aspx?FamilyID=7b43bab5-a8ff-40ed-9c84-11abb9cda559&displaylang=en
It's required for SOAP and JSON endpoints
The SoapXmlEndpointFactory
class is part of the
Microsoft.ServiceModel.DomainServices.Hosting
assembly, which is included in the Silverlight Toolkit.
See here
<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>
Declare this in the ConfigSections. It's important to include the sectionGroup correctly
精彩评论