- Install the following two updates:
- Add a reference to "Microsoft.ServiceModel.DomainServices.Hosting" to your web application project
- Add the following to your web.config into the
tag <domainServices> <endpoints> <add name="OData" type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <add name="Soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <add name="Json" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> endpoints> domainServices>
- Here the first pitfall arised; the application did not compile anymore complaining:
The "CreateRiaClientFilesTask" task failed unexpectedly.
Unrecognized configuration section system.serviceModel/domainServices.
To resolve this add the following to thetag: <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>
- According to some howtos the URL is composed as follows:
http://localhost:[port]/[Name of Silverlight Project]-Web-[Name of Webservice]/Json/[Method name]
e.g.: http://localhost:2002/MySilverlightApp-Web-DataAccessService/Json/GetArticles - The above URL always returned 404 Not found
- My next pitfall was that my service class file was not in the web project but in a subfolder ("Services") of it
- To solve that I had to modify the URL as follows:
http://localhost:[port]/[Name of Silverlight Project]-Web-[Folder name]-[Name of Webservice]/Json/[Method name]
e.g.: http://localhost:2002/MySilverlightApp-Web-Services-DataAccessService/Json/GetArticles - After that I finally got my JSON from my webservice :-)
Wednesday, April 11, 2012
WCF RIA Services with JSON endpoint
Today I had the task to add a JSON endpoint for a WCF RIA service for which there exists a Silverlight client.
I wanted to state some problems that I encountered such that maybe others can get it to work faster:
Subscribe to:
Posts (Atom)