Muhammad Ali Khan

MS CRM 3.0, MS CRM 4.0, Sharepoint 2007 & Sharepoint 2010

Creating Custom WebService In SharePoint 2007

Posted by Ali Khan on August 7, 2009

In this post i am going to show you how to create a custom webservice in sharepoint 2007. There is already an article (Hello World Webservice) on msdn about this.

Except the fact, the article on MSDN wants you to create the WSDL and DISCO file for yourself, which I found out to be very hectic and time consuming. Instead we can just use any tool that will generate the WSDL and DISCO file for us.

1.    As First Step, Create a class library in Visual Studio 


2.    Add the references to the “Microsoft.Sharepoint.dll” and “System.Web.Services” dll



3.    Add a new class and inherit it from “Webservice” class


4.    Sign the assembly. As it will be deployed in GAC




5.    Write your code for the custom webserivce. Here are just two methods for renaming the folder in a document library




6.    Build your project and install it in GAC.




7.    Create a custom SPFolderWS.asmx file which will point to the SPFolderWS.cs (which you defined in the class library, and is installed in GAC). Note this file “SPFolderWS.asmx” doesn’t need to be in the project.




8.    Use the SPDev Tool to generate the DISCO and WSDL file for you. ( You can download the SPDev Tool from the following website)




9.    Here are your generated WSDL and DISCO file.



10. Copy these files to the “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI” directory




11. Browse the URL to make sure the webservice is properly deployed



12. That’s it.

Now to test the above webservice, we will create a console application.

1.    Create a Console Application, and add the reference to the webservice as shown below




2.    Write the following code snippet to call the methods of the custom webservice.




3.    If everything works fine, the folder should be re-named.



 4.    That’s All

You can also download this code from the following location.

Custom WebService Code


9 Responses to “Creating Custom WebService In SharePoint 2007”

  1. […] Creating Custom WebService In SharePoint 2007 […]

  2. Dipti Chhatrapati said

    Thank you very much , this article has removed my confusions regarding Deployment of web service in sharepoint

    Thanks Again 🙂

  3. Denis said

    Thanks a lot for this example!
    One question though: what should we do with What should it link to precisely?

    All the best

  4. Abraham said

    Hi Ali,
    It was incredible. simple and sweet, I have been messing with this issue for the last 3 days and this article helped to fix it. Great work.

  5. Rajesh said

    It was really a nice well complied article without any confusion..keep posting

  6. Yourfan said

    Great article! Helped me lot.

  7. Dan said

    I get a message that web service .disco file in not a valid disco file. Any pointers?

  8. Very nice explanation !!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: