Do you know that? Outsource to other designers when you are busy. next

Explain the steps to create a web services and consume it.

Steps to create and consume a webservice

Creation:

  • a. Create a new website by selecting "ASP.NET Web Site" and giving it a suitable name.
  • b. service.cs file appears inside the solution with a default webmethod named as "HelloWorld()"
  • c. Right click on the webservice project and add a web reference instead of adding a normal reference.
  • d. A window appears that displays a list of webservices knows to the solution.
  • e. Click on "Webservices in this solution"
  • f. a search progress bar appears and
  • g. Select the service that appears in the list
  • h. progress bar appears once again.
  • i. web method appears on the screen
  • j. Click on "Add reference" button. This would add localhost
  • k. solution would have App_WebReference folder

Consumption or Usage:

  • a. Add a UI (.aspx) to the webservice project
  • b. Add a button and a label to the form
  • c. Double click the button to see the click event of the button
  • d. Create an object of type service localhost.serviceName
  • e. Write code to display the value returned by the webmethod on the label
  • f. Execute the solution by setting the added aspx as the startpage.
  • g. click on the button and the message "Hello World" would be displayed on the label