EPiServer Template Foundation WCF REST JSON service, part three
This blog series is about extending EPiServer Template Foundation (ETF) with a WCF service that can be accessed with REST and returns JSON. This is the final part in a series of three. The first and second parts are available here and here.
Building the project and adding it to the EPiServer website
Right click the WCF Services Application project and select Publish. Select File System as Publish method and target location to a location of your choice.
Browse to the target location folder. Copy the project assembly from the bin-folder and into the website bin-folder. Finally copy the service folder to the root of your website.
This can of course be automated by adding post-build events to the WCF Service Application project.
We need to add the .svc-extension handlers. Otherwise our REST calls are going to end up as 404-errors.
Add the following handlers after the <clear/>-element.
<add name="svc-ISAPI-2.0-64" path="*.svc" verb="*" type="%SystemRoot%Microsoft.NETFramework64v2.0.50727aspnet_isapi.dll" resourceType="Unspecified" preCondition="integratedMode" />
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" type="%SystemRoot%Microsoft.NETFrameworkv2.0.50727aspnet_isapi.dll" resourceType="Unspecified" preCondition="integratedMode" />
<add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089" resourceType="Unspecified" preCondition="integratedMode" />
Next we need to add the service to the <system.serviceModel>-element and define endpoints and a behavior for our service.
<service behaviorConfiguration="MetadataBehavior" name="DBLOG.EPiCMS6Sandbox.Services.ETF">
<endpoint address="" binding="webHttpBinding" contract="DBLOG.EPiCMS6Sandbox.Services.IETF" behaviorConfiguration="WebBehavior"/>
<serviceMetadata httpGetEnabled="true" httpGetUrl="" />
The result is in.
By using the same technology you can use your strongly typed pages in EPiServer along with the standard page types in ETF and expose these as JSON using REST.
With ETF there’s a possibility of creating a base plate Windows Phone 7 application which uses these REST services. Stay tuned for that one… 🙂
So now when the client asks you: “Well, EPiServer CMS seems to be really cool. But we want to extend our website to apps for Windows Phone 7, iPhone and possibly Android as well. How are you going to solve this for me?” you can just tell them: “ETF WCF REST JSON. What up?”