Deploy a Custom WCF into SharePoint2010—Part 1
In SharePoint2010, it has lots of asp.net web services as well as some new WCF services to be used in your client application. The new client object model in SharePoint 2010 uses WCF as well. However, most of the built-in web services are generic and does not use your own business object. If you would like to have object that matches your own business scenario, you need to create your own WCF services. Today, I will show you how to create and deploy your custom WCF. You can download the source code here.
1. Create a new empty SharePoint project and deploy it as a farm solution.
2. Add 3 WCF Service Library projects into the solution as shown below. The reasons for this project setup are explained in a video screencast here.
3. In the YBBEST.WCFServiceImplementation project, add these YBBEST.WCFServiceContract and YBBEST.WCFDataContract project references.
4. In the YBBEST. WCFServiceContract project, add YBBEST.WCFDataContract project references.
5. Add the classes needed for the WCF project as below.
6. Add ISAPI SharePoint Mapped Folder to the YBBEST.CustomWCF SharePoint project, add YBBEST folder and in the folder add web.config file, add CustomService.svc file.
8. Add the following to your web.config
9. Add the key from the YBBEST.CustomWCF project to the 3 WCF projects as a Link and sign the project using this key. For detailed explanation, please check MSDN article.
10. Add the project output dlls to the SharePoint Package for deployment into SharePoint.
a. Go to Package of the YBBEST.CustomWCF SharePoint project
b. Add Assembly from Project Output as below.
11. Deploy the project to your SharePoint server and navigate to the service url http://ybbest/_vti_bin/ybbest/CustomService.svc , you will find the following message, since I do not enable Metadata publishing for this service.
12. You need to change your web.config as follow to enable Metadata publishing for this service.
You can download the source code here.