SharePoint Events

 11/18/15 - Webcast: Collaborative Project & Program Management for the AEC & Facilities with SharePoint & Office 365
 11/19/15 - Webcast: Easily Design, Brand and Enhance the User Experience of SharePoint and Office 365
 12/01/15 - Webcast: Legal Matters Management in SharePoint & Office 365
 12/02/15 - Webcast: Easily and Cost Effectively Migrate to Office 365 and the Cloud
 12/03/15 - Webcast: AEC and Facilities Document Control with SharePoint & Office 365 (RFI/Transmittal/Submittal Management)
 12/04/15 - Webcast: Drive User Adoption & Search with Automated Metadata in SharePoint
(More Links...)

 SharePoint Videos

 What’s Coming in Office 365 & SharePoint 2016
 Automating Contract Management with Workflow in the Cloud or On-Premise
 Manage Email in the Cloud or On-Premise with SharePoint & Office 365
 Governance Essentials for SharePoint 2013 and SharePoint Online
 Easily Move Email, Files and SharePoint to Office 365
 Enterprise Workflow in the cloud with SharePoint & Office 365
 Why SharePoint 2013
 SharePoint 2013 vs SharePoint Online and Office 365 Security, Compliance and eDiscovery
 Expanding the Use, Potential and Value of SharePoint and Office 365 through 3rd Party Applications
 Keys to Successful SharePoint Initiatives and User Adoption
 SharePoint 2013 vs. SharePoint Online: Workflow
 Ensure Auditability and Compliance with Advanced Workflows in SharePoint
 SharePoint 2013 vs. SharePoint Online and Office 365: Enterprise Content Management
 SharePoint 2013 vs. SharePoint Online and Office 365: Business Intelligence
 SharePoint 2013 vs. SharePoint Online: Search
 Power Business Intelligence for SharePoint Online and Office 365
 Enforce Governance with Ease in SharePoint and SharePoint Online
 Digitize Paper Driven Processes with Dynamic Web Forms in SharePoint
 Boost Performance and Eliminate Storage Limitations in SharePoint
 Out of the Box Business Intelligence and Reporting in SharePoint 2013
(More Links...)

 Archives ‭[1]‬

Opening SharePoint Links in a new window
Mail Enabled Lists vs. The Missing Windows 2008 POP3/IMAP Server 
7 Tools for SharePoint Developers
Public Facing Masterpage Techniques
How to Quickly Deploy and Activate a Timer Service to Your Site Collection
Custom SharePoint Master Page Feature with WSP Builder
Date Math with InfoPath
Enterprise Search Tricks and Tips Part 1
Populating Word Documents With SharePoint Data. Try The DIP!
Programmatic Deep Dive into Blank SharePoint Lookup Columns
1 - 10Next
How to Create WCF Web Service on SharePoint 2010

By: Arjun Chakraborty

Today, I’d like to talk about how to create a WCF Web service for SharePoint 2010.  As you may know, currently there are no standard templates for creating web services for SharePoint 2010.  However, with a little tweaking, we can still create effective web services for SharePoint.  Here is how I approached creating a WCF Web Service on SharePoint 2010:

NOTE*: these steps require activating ‘anonymous’ authentication in IIS.   Despite anonymous authentication being active, SharePoint will still require you to sign in using your own credentials.  It would seem, IIS credentials are independent to SharePoint credentials.

1)    First, Create an Empty SharePoint Project on Visual Studio 2010.  I’ll call this project WCFTest001.  Make sure it is set it to Deploy as a Farm solution:

2)      Save the Project.  Then, right-click on the project and click on “Unload Project”.

Then, right click on the project again, and click on “Edit WCFTest001.csproj” (or whatever your project’s name is).
Then, add the following line:
Make sure this line is below <SandboxedSolution>False</SandboxedSolution>, which is already in the .csproj file!

Lastly, save the .csproj file, and click on reload project.
This is a very important step, because it sets the necessary namespaces for the service file mentioned in step 4.

3)      Now, we need to add the _vti_bin to the SharePoint project.  To do so, right click on the SharePoint Project, go to add, click on “SharePoint Mapped Folder…”
Select “ISAPI”, and press Okay. 

You should now have an ISAPI folder under the project:


4)   Right click on the ISAPI folder, and click on Add, and then New Item….  Select a text file under the General Tab.  Name it however you like, but make sure it has .svc as its extension.  I’ll call it WCFTest.svc.

Before we populate this file, first we need to create the code behind.  To do this, right click on the solution file, and click on Add and then New Project.  Add a project of type WCF Service Library.  I called mine WCFLib, because we will only be taking 2 files from that project and then removing the project from the solution.
The two files we want are IService1.cs and Service1.cs.  Copy those two using the Visual Studio Solution Explorer Pane, and paste them under WCFTest001:
Now, simply remove the WCFLib project from the solution.  I would also go ahead and create a simple class under WCFTest001 so I can copy paste the project’s namespace.  In this case, I left the class’s name as the default Class1.
Now, about those two files; The IService1 file declares the methods and objects that will be exposed by the web service.  The Service1 file actually implements those methods and objects.  Go ahead and rename them as you wish.  I will rename them as Test001Service.cs and ITest001Service.cs.  ALSO, I will change their namespace to that of this project!

At this point, you probably have a ton of errors.  This is because we do not yet have all the necessary references.  You will need to add the following references to your SharePoint project:

- System.ServiceModel
- System.Runtime.Serialization
- Microsoft.SharePoint.Client.ServerRuntime.dll  (this can be found in C:\windows\assembly\GAC_MSIL\Microsoft.SharePoint.Client.ServerRuntime\[something]\Microsoft.SharePoint.Client.ServerRuntime.dll )

At this point, all of your errors should have disappeared.

Take a look at the ITest001Service.cs file for a moment.  You will see 4 kids of tags; [ServiceContract], [OperationContract], [CompositeType], and [DataMember].  If you want to expose a web method (And, of course you do.  Why else would you make a web service?), then you have to use [ServiceContract], and [OperationContract].  [ServiceContract] designates a web service, and [OperationContract] designates a web method within that web service.  If you want to use non-primitive objects as parameters or return values for your web methods, then you must use the [CompositeType], and [DataMember] tags.  [CompositeType] designates an Class/Object, and [DataMember] designates a public property to or from which the client application (or whatever) stores or extracts data.

Also, let’s take a look at the Test001Service.cs because there are a couple important additions to make:


Notice the 4 using statements added inside the namespace, and the 2 tags added before the web service class.  These are necessary.

Now that we know the cs file name, namespace and class name, we can finish up the .svc file.  Open the WCFTest.svc file and paste:

ServiceHost Debug="true" Language="C#" Service="WCFTest001.Test001Service, $SharePoint.Project.AssemblyFullName$" CodeBehind="Test001Service.cs" %>

Note: you should change the values for the ‘Service’ and ‘CodeBehind’ attributes to fit your own service.  The Service simply points to the full namespace and class name for the web service.

Lastly, save the .svc file.

5)   Create the web.config file:

Right click on the ISAPI folder in Solution Explorer, and add another text file.  This time, make sure to name it “web.config”.

Set the web.config contents to:

<?xml version="1.0" encoding="utf-8" ?>





        <behavior name="WCFTest001.Test001ServiceBehavior">

          <serviceMetadata httpGetEnabled="true" />

          <serviceDebug includeExceptionDetailInFaults="false" />





      <service behaviorConfiguration="WCFTest001.Test001ServiceBehavior"


        <endpoint address="" binding="basicHttpBinding" contract="WCFTest001.ITest001Service">


            <dns value="localhost" />



        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />





NOTE: make sure to edit the values I’ve set to red.

In the end, the project should look like this:


6)   One more step before testing.  We need to enable ‘Anonymous’ Authentication in IIS for the applicable web applications.
Go to IIS through start -> administrative tools. 
Click on the applicable web application under the sites folder, and then click on the Authentication icon.


Then, enable Anonymous authentication:


7)   Finally, right click on the project, and click deploy.  Once Visual Studio says “Deploy Succeeded”, check out any SharePoint site to see if the web service exists.  To do so, use the following url: site_url/_vti_bin/service_Name.svc.

In my case, its http://arjunsp01:10000/_vti_bin/wcftest.svc

When the SharePoint project is deployed, it is deployed as a wsp file into Central Administration.  However, there are no features involved.  This web service is now available to every site on the farm.  However, it can only be used on the web applications where anonymous authentication is enabled.
The result should look something like this:


If you get this result, then the web service is working, and should be consumable by client applications and what not.  Next time, I will go over how to create asmx web services for SharePoint, which is slightly easier.


This article only reflects my own experience with creating web services for SharePoint.  If you have any complaints, questions or additional notes, please feel free to leave a comment.


Most of my knowledge regarding this matter came from:

·     This excellent MSDN article:

·     Conversations with Microsoft technical support.

·     Personal testing.


By: Arjun Chakraborty



  GigWerks RSS  Gig Werks Mailing List 

 Contact Us



 On Demand SharePoint Webcast Recordings
 Upcoming Webinars
 SharePoint Resources
 Business Intelligence Resources
 Gig Werks Website

©2009 Gig Werks. All rights reserved. Privacy Policy