0

I am trying to host a custom web service in SharePoint 2007 (WSS 3.0) and so far I have followed the instructions here to create a simple 'Hello World' web service: Create WSS Web Service

However, when i get to the virtual path bit in step 4 I am struggling to see in visual studio how I create this and then deploy to make a virtual path to make my web service accessible.

Can anyone help me sort out creating a virtual path for WSS or point me in the direction of another guide to create and host a web service in SharePoint?

Thanks in advance...

Luke
  • 422
  • 5
  • 15

2 Answers2

1

You need to register the module in the web.config under configuration/system.web/httpModules.

      <add name="ArbitraryName" type="Namespace.ClassName, AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXXXX" />

Then you can put it in any directory you'd like. If you're using WSS 3.0 check to see if the previous virtual path provider has a name of "SPVirtualPathProvider". If you're using MOSS 2007 check to see if it has a name of "CmsVirtualPathProvider".

Daniel Larson does a decent job of walking you through it in Chapter 11 in his book Developing Service-Oriented AJAX Applications on the Microsoft Platform.

The best way to do this is normally a FeatureEventReceiver using the SPConfigModification class. This way it pushes out to all the servers in your farm.

Cameron
  • 26
  • 2
  • @Luke The double quotes above were a mistake. I copy and pasted from some code that I had and I was using @string. You can find source code and instructions from the above mentioned book's companion content at http://www.microsoft.com/mspress/companion/9780735625914 in the appendix section. – Cameron Feb 24 '11 at 05:33
  • Thanks for this, I will look at implementing this when I get 15 minutes spare but on first glance it looks like it will resolve my problem... If it does I will mark your answer as the answer... Cheers – Luke Feb 26 '11 at 15:34
  • I havent had time to look at this yet and am not going to get the chance for a while yet but at a glance it looks like it will help me solve my problem. Thanks for your help... – Luke Mar 07 '11 at 21:54
0

You can host a web service in a _layouts folder for example. Just create some folder there (like "MyService"), put your .asmx, then put your web service .dll in GAC (don't use code behind). Restart IIS and you service would be available at http:///_layouts/MyService/.asmx.

EvgK
  • 1,907
  • 12
  • 10
  • Thanks for that, I have not managed to build an .asmx web service, with the instructions i have followed I finish up with a .svc file... can I do the same with this? Or if i create a .asmx web service, can this be called in Silverlight v4? Cheers – Luke Feb 01 '11 at 21:27
  • Oh, so you'd better follow instructions above, because you can have problems with .asmx in Silverlight4. In step 4 of this instruction you need to create and register a IHttpModule, which will register your specific VirtualPathProvider. What exactly the problem is? You can also use this project: http://spwcfsupport.codeplex.com. Using it, you can host WCF service in SP2007 without manual writing IHttpModule and VirtualPathProvider. – EvgK Feb 01 '11 at 21:51
  • I know it mentions this on step 4 and I have tried this but still had no joy... do you know where I would find some step-by-step instructions to create and deploy/register an IHttpModule? Thanks – Luke Feb 09 '11 at 20:44