Super Easy way to add WCF to SharePoint 2007: www.codeplex.com/SPWCFSupport

Posted on 9/8/2008 @ 9:11 PM in #SharePoint by | Feedback | 14881 views

 

 

Download it here - http://www.codeplex.com/SPWCFSupport

 

 

I blogged earlier about "SharePoint as a WCF host". Specifically there are 4 easy steps -


Table of contents

- Basics -

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.

 

- Real world -

1. Adding WCF Support to a website. <-- You're here!

2. Deploying WCF EndPoints as solutions.


Well, I've made all that much simpler.

To add WCF support to your SharePoint site, simply use the following steps -

a) Download the project from www.codeplex.com/SPWCFSupport

b) Install the solution (or feature) --- I haven't made the solution yet. Will do that soon.

c) Through Central Admin --> Application Management --> Manage Web Application Features .. activate the feature to the website you are trying to add WCF support to. The feature you wanna activate looks like this -->

 

  

d) Create a wcf home, which is as simple as Create a directory under the virtual directory that hosts your SharePoint site. Example - c:\inetpub\wwwroot\wss\virtualdirectories\80\_wcf

e) That's it. Now start throwing your endpoints in there.

Windows 2008 specific instruction - You may need to run the following command to fix the Mime types and IIS Metabase

"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y

For more details, please read: Host a WCF Service in IIS 7 & Windows 2008 - The right way

 

_________________________________________

Finally: A little comment - WCF is a big complex topic. Not every WCF service will work easily with SharePoint. Specifically where you will frequently tear your hair is around authentication issues. This project doesn't read a WCF book for you :-), you still need to learn WCF. I recommend either Juval's or Michelle's book on WCF.

_________________________________________

Sound off but keep it civil:

Older comments..


On 5/26/2008 12:47:20 PM Peter said ..
OK, so...hypothetical question: if there were some unannounced features of SharePoint vNext, and you were given an early access look at some of those features...would WCF integration be one of those?

Anyway, these WCF articles came out of "nowhere", so I'm curious. I know you can't answer.


On 5/26/2008 4:16:09 PM Sahil Malik said ..
Peter -

You almost gave me a heart attack. LOL.


I read over everything I wrote once again to ensure I didn't leak any NDA details.

Umm .. I'm not sayin' nothin'! And frankly, even if I did say anything, MSFT can always change it's mind on stuff.

BTW - Over the next month or three you will see plenty of .NET 3.5 + SharePoint articles on my site. So these didn't come out of nowhere - I just have a huge backlog of stuff to write about. Thats all!

SM


On 6/2/2008 2:00:23 PM Ryan Miller said ..
I just put together a project where I wrap up and deploy this web service as a SharePoint solution. It's pretty much just merging your project in with the smart templates project(http://www.codeplex.com/smarttemplates). You can get a handle to it on my blog www.intranoggin.com or just pull the source from the downloads at www.mylocalbroadband.com .

The SharePoint solution architecture does a great job of deploying front end applications across a multiserver farm. I'm exploring the use of the .wsp as a tool to deploy web services in the middle teer as well. Your solution and article were a huge help.


On 6/2/2008 9:38:58 PM Sahil Malik said ..
Ryan - that is super cool. Have you considered putting .svc's in document libraries? I see no reason why that should not be possible to do - and it'd make deployment hella easier too!


On 6/4/2008 1:56:49 PM Ryan Miller said ..
I tried to post back yesterday, but I think I may have forgotten to enter the code, so...

That's cool, I hadn't thought of that, but ultimately, you would still need to get the .dll in the GAC and the entries made to the web.config. I had thought it would be cool to write a event receiver that would take .wsp's posted to a document library and install/deploy them. There's a codeplex project that adds the ability to upload solutions through the central admin site; this would make a great start. I won't be getting around to it any time soon, so if you beat me to it the glory is all yours.


-Ryan


On 7/23/2008 2:59:17 PM Brock said ..
Thank you so much for putting the feature together to enable WCF in SP -- just what we were looking for.

I know you give caveats about authentication -- which is exactly what I am hitting with a

System.ServiceModel.Security.SecurityNegotiationException was unhandled


Message="The caller was not authenticated by the service."


Source="mscorlib"


StackTrace:


Server stack trace:


at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)

Can you give a few tips / links on how to solve (I did get Michele's and Juval's books -- but it is going to take a while to dig through 1000 pages :)

Thanks,

Brock.

P.S. My client is going to be in Java -- so I would really prefer simple or no authentication if possible -- not sure if we can get away with it if SP is hosting the WCF.


On 7/23/2008 3:07:39 PM Sahil Malik said ..
Hey Brock - hard to comment without looking @ your configs.


On 7/23/2008 3:07:51 PM Sahil Malik said ..
Hey Brock - hard to comment without looking @ your configs.


On 7/23/2008 5:01:05 PM Brock said ..
Hi Sahil --

woo hoo -- got it to work !!!

for some stupid reason I was using WsHttpBinding -- just switching to BasicHttpBinding made it all work.

Thanks again for the good stuff.


On 7/28/2008 8:14:12 AM Adam Buenz [WSS MVP] said ..
Excellent project Sahil!


On 7/28/2008 9:51:06 AM Sahil Malik said ..
Thanks Adam.


On 12/30/2008 8:17:35 AM Tibi Molnar said ..
Hi Sahil,


thank you for the article. I have an interesting problem, maybe you have an idea: in the dev env I have WSS 3.0, Win 2K3, IIS 6. I am using ADO.NET data services hosted in the LAYOUTS directory, I have my custom virtual path provider, everythink works kool.

In test env the difference is that I have Win 2008 server with IIS7, the result: I got HTTP 404 when calling the Ado.Net data service. ServiceModelReg.exe was executed. Information what I have in addition is that the virtual path provider FileExists method is not calledd anymore for the Ado.Net svc file!

Do you have an idea?

Cheers,

Tibi


On 1/13/2009 11:43:28 PM Prathibha said ..
I have a requirement to access a MOSS site (internet enabled/ customer facing) to get the names of all the people in a particular site through the object model. Its working fine with a normal class library, but giving issues when we register this as a service running out of IIS.

The service is running on anonymous access whereas the MOSS runs on integrated windows. When accessing through the service, an exception says that the site is not found. Is it something to do with the access rights?

Note :A normal BO is there which is invoked by the service class to query MOSS. Is this a concern?

Any help is appreciated!


On 12/21/2009 2:49:32 AM Taha said ..
Hi Sahil,

Thanks. I am able to succefully deploy and use the wcf service having deploying it to _vti_bin. This works fine in single server installation where as on a multiple wfe server farm , it gives virtual path error.

Does the virtual path feature that is available from codeplex takes care of farm deployment? if not, then can you plz suggest a work around?

Thanks,


Taha


On 12/22/2010 2:48:20 PM DavidEvan said ..
Unfortunately GAC deployment is not allowed for us. Can you elaborate on getting this to work in BIN deployed partial trust scenario in SharePoint MOSS? In this context can you elaborate further on the WSP deployment process that should be used?