Create and Consume WCF in Sharepoint

本文指导如何在SharePoint环境中部署WCF服务,通过创建SharePoint项目、添加关键引用和配置服务接口来实现服务与SharePoint的整合,最终通过svc文件验证服务部署并测试其在客户端的可用性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In this case, you needn't create a seperate Web site for the WCF services, the services will share the same web and port number with existing sharepoint site. Because it is a farm solution, once it is deployed, it will be shared in the whole farm.

 

Here are the steps,

 

1. Create a new Sharepoint Empty project "SPFirstWCF".

 

2. Add Reference.

    a.  System.ServiceModel   

         this one is the core assembly for WCF

    b.  Microsoft.SharePoint.Client.ServerRuntime

         This contain the attribute [BasicHttpBindingServiceMetadataExchangeEndpointAttribute] which allows SharePoint to automatically support metadata exchange endpoints, and is the secret sauce that allows us to develop custom WCF services without having to deploy endpoint configuration to the SharePoint web.config.

         This assembly is locating at %Windows%/assembly/GAC_MSIL/Microsoft.SharePoint.Client.ServerRuntime

 

3. Add a SharePoint Mapped Folder to the ISAPI folder, and create an empty text file with the .SVC extension. Note that it is always a good practice to create a sub-folder when deploying your custom code to the SharePoint file system. It helps keep you custom code separate from the original installed files.

 

4. Create WCF service Interface

 

5. Create WCF service class

6.  The assembly will go to GAC after the deployment. You can check its public token and version number

7. Based on above information, modify the svc file

8. Deploy the solution to the sharepoint farm. you can use this link to check whether it is working

   http://localhost:26292/_vti_bin/GSWCF/gswcf.svc/mex the mata data info should be returned.

9. Create a test console project and add the service reference by using that service URL.

Here is the code,

ALL done!!

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值