Tuesday, June 23, 2009

System.IO.FileNotFoundException: The Web application could not be found.


If you are getting the above error when performing some operation in you Web Service / Web Appliation with Sharepoint server. You can resolve this by adding the Sharepoint application pool in you custom Web Service / Web Appliation :

In the IIS, you need to open the property page of the Web Service / Web Appliation that you host. under "Home Directory" Tab, you can chose the appliction pool. make sure that your sharepoint web appliction and your webservice sharing the same application pool name.


To interact with a SharePoint Server from out side the SharePoint web server it self, you need to write a SharePoint web service. SharePoint web services are nothing bur regular web service, only difference is that they are configured into the SharePoiint site configurations. And from inside the Web service you can do whatever possible with the Object model.

To get the SPSite instance from inside the web service, you even dont need to specify domain names, ip etc. Just doing the following you can have an instance of SPSite

SPSite siteCollection = SPControl.GetContextSite(HttpContext.Current); OR
SPWeb subSite = SPControl.GetContextWeb(HttpContext.Current);

After creating and deploying a web service into the SharePoint you can talk to the web service from anywhere of the world and the web service will actually make use of object model to talk to SharePoint.

No comments: