|
|
|
|
|
|
|
|
|
|
 |
| Copy to Clipboard | _layouts/images/ConvertDocument.gif | javascript:window.location= '{SiteUrl}/_layouts/SmartTools.CopyPaste.Copy.aspx?listid={ListId}&itemid={ItemId}&Source=' + window.location | 0x0 | 0x1 | ContentType | 0x0101 | 2147483647 |
|
|
|
 |
|
|
|
|
|
IntraNoggin > Posts > Packaging a WCF Service as a SharePoint Solution
|
6/2/2008Infrastructure Setup:
- Install the SharePoint WCF Support Solution from Sahil Malik on CodePlex http://www.codeplex.com/SPWCFSupport
- Create a folder called '_wcf' at <sp path>\12\ISAPI\_wcf . This folder is now available for every site at <site url>/_vti_bin/_wcf .
You only need to enable it in the web applications where you want to host the services, and you don't need to enable anonymous access to the whole web app, just on the _wcf folder. Go to your web app in your iis manager and right click on the _vti_bin
- Add the xml containers to the web.config for the web app you want to deploy the service to. For me this meant going to C:\Inetpub\wwwroot\wss\VirtualDirectories\80\web.config and adding this xml node directly after the </configSections>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
</serviceBehaviors>
</behaviors>
<services>
</services>
</system.serviceModel>
I'll then use a feature receiver to insert the <behavior…> node and the <service…> node when the feature is activated.
Service Packaging:
- Write your WCF service as you normally would. The Winsmart site above has a great Hello World primer I recommend starting with if you haven't done one yet.
- To make it work as a SP solution, package your solution so that: *see my example below
- The .dll gets GACed
- The .svc file gets put in the _wcf directory
- Create the feature receiver to insert the <behavior …> and <service …> nodes. Your base address will be http://localhost/_vti_bin/_wcf/
- Add and deploy your solution, then, in central administration, for the web application you want to use the WCF service, activate both the WinSmart feature and your service feature.
- You can then point your browser at http://<any site url>/_vti_bin/_wcf/helloworld.svc to see the service definition and in your test harness, you can create a service reference to http://<any site url>/_vti_bin/_wcf/helloworld.svc .
My Example:
I used Visual Studio 2008 for mine. To make the service packaging easier, I started with the Smart Templates project from Codeplex (http://www.codeplex.com/smarttemplates). I created the project then wiped out the web part files and created the wcf files following the WinSmarts example. The guts of the feature receiver code, I took again from WinSmarts, but this time from the source to the WCF Support Solution. I went through several tweaks before I got the whole thing working together, but I'm making the working version available on www.mylocalbroadband.com or get it directly here.
| Copy to Clipboard | _layouts/images/ConvertDocument.gif | javascript:window.location= '{SiteUrl}/_layouts/SmartTools.CopyPaste.Copy.aspx?listid={ListId}&itemid={ItemId}&Source=' + window.location | 0x0 | 0x1 | ContentType | 0x0101 | 2147483647 |
|
|
| Copy to Clipboard | _layouts/images/ConvertDocument.gif | javascript:window.location= '{SiteUrl}/_layouts/SmartTools.CopyPaste.Copy.aspx?listid={ListId}&itemid={ItemId}&Source=' + window.location | 0x0 | 0x1 | ContentType | 0x0101 | 2147483647 |
|
|
|
|
|
|
|
|
|
 |
 |
 |
 |
|