Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm fighting with Services deployment under the SharePoint infrastructure.

It happens that I spent a lot of time trying to configure a REST SharePoint 2010 web service under the ISAPI (_vti_bin) folder. The service works after a simple deploy but I cannot find a way to get Users' info.

I tried to access it by

  • SPContext.Web.CurrentUser
  • ServiceSecurityContext.Current.WindowsIdentity.Name
  • Thread.CurrentPrincipal.Identity.Name

But everytime it was null. I tried to apply a custom web.config on my Web Service so that I can specify the impersonation and so on but I cannot resolve the problem.

I solved the problem deploying it under Layouts so I ask:

  • What's the difference between the two folder (in behavior, I already know the location and the distribution across web applications)?
  • Why ISAPI is preferred for web service deployment?
  • Is there any "good practice" I'm violating deploying it under layouts?

Thank you very much

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you deploy your web service to the layouts directory, you may run into some unexpected behavior with your web service.

ISAPI is the best practice location to deploy any custom web services. This is because this folder is set up to serve your web services via wswsdl and wsdisco.

As explained by James Tsai in his article Where do you deploy custom SharePoint web service files to?:

[The] _vti_bin (12\ISAPI) virtual folder has been configured to serve requests differently compared to other virtual folders in the SharePoint site.

Every web service request made to this directory will be parsed by wswsdl.aspx and wsdisco.aspx files in 12\ISAPI. wswsdl.aspx and wsdisco.aspx files then find correspondence (sic) wsdl and disco information for web service request and output correct contract reference and SOAP address.

...

Without this mechanism (web service request made to any other virtual folder on SharePoint site) the ASP.NET auto-generated disco and wsdl will be used. Since auto-generated disco and wsdl are unaware of the SharePoint service URL virtualization, results returned by web service become unreliable.

Check out the link for a test / proof of concept.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.