Table of Contents for SharePoint as a WCF host.
1. Create a WCF Home. This is the virtual directory that will host all your WCF endpoints.
2. Create a WCF Service Library, and throw it in the GAC.
3. Create a relevant .svc file in the WCF home you created in step #1.
4. Write a WCF Virtual Path Provider, and register it in the SharePoint site.
The first thing you need to do is find a home for your WCF services. You could put them inside _layouts or _vti_bin, but I like to keep things clean and create a new home for them for the following reasons:
a) You will be adding significant information in the web.config
b) Isolation
c) Won't interfere with Microsoft's future updates.
Okay thats great, so lets get started. You can create such a WCF home using the following steps -
- First, create a physical directory. I like to create it inside the same virtual directory that is hosting my SharePoint site. This way, all relevant security permissions are simply inherited. I created a dir at C:\Inetpub\wwwroot\wss\VirtualDirectories\80\_wcf.
- Next, on your port 80 (or whatever port you are WCF enabling), through IISMGR, create a new virtual directory .. call it _wcf, turn it into an application, and give it execute and read permissions.
- Run the following - "%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y
Okay good, your home is all setup.
Next, create a WCF Service in a WCF Service library, and throw it in the GAC.
After which, you can create a .svc file.