Monday, October 1, 2012

How to Create Web Service in Microsoft Visual Studio 2008 in Windows7

Here I am going to explain you how to develop web service in Microsoft Visual Studio 2008.

You need Internet Infomation Server (IIS) 7.5 as virtual server to run the web service.

You can download IIS 7.5 from here.
You need Dot Net Framework 3.5 to install IIS 7.5 You can download it from this link.

Now to configure IIS you have to go in control panel - > Programs and Features -> Turn Windows Features on or off.

Click on  Turn Windows Features on or off.

Now check 2 check box listed below :

  • Internet Information Service
  • Internet Information Service Hostable Web Core
Now Click on OK button and Restart your computer.

Now, You can check whether your web server works properly or not by following step :
  • Open your web browser and type localhost
  • If it successfully show you IIS 7 page then your web service will work properly otherwise something goes wrong.
Now Time to implement web method. To develop web method you need to open Microsoft Visual Studio 2008 in Administrative mode. You can right click on Microsoft Visual Studio 2008 and click on Run as Administrator. It will open IDE of Microsoft Visual Studio in Administrator mode.

Now to develop new web-service follow the following steps :

  1. You have to create new project so that go to File Menu -> New -> Website
  2. Select ASP.NET Web Service in Template.
  3. Now following window will be appear.

    3.  Now select HTTP in Location Option form Drop Down box because our method is resides on server and provide name of your web-service in following format : http://localhost/your-application-name.
    4.  Now select Visual Basic in Language Option because here I am going to explain code in VB,
    5.  Now click on Ok button.
    6.  By Default one method named HelloWorld will be created and it will return HelloWorld while one can invoke it.
    7. Define your own method and specify your logic.
    8. Do not forget write <WebMethod()> _  at every beginning of  method because it defines that this method is web method and called by application. If your not specify <WebMethod()> _  then that method will be used as private/local method.
    9. Now your web method will be define successfully.

You can manually run your web service from browser by written as follow :

http://localhost/your-application-name/Service.asmx


Android Code for calling web service method click on this link

0 comments:

Post a Comment