Wiki Search

CS 352 Wiki Web Development 3

| edit page | page history | Sign in |

Day 6 Wiki Notes main content

Notes Index

Web Services

In simple terms, Web Services allow software to communicate using a standardized XML messaging system over the Internet.

Like many Web technologies, the World Wide Web Consortium has taken a leading role in defining the set of technologies enabling Web services

Typical Web services include

Web Services with Visual Studio

Microsoft has made the construction of Web Services relatively easy with the use of Visual Studio 2008. Spend some time at (MSDN Web Services) and read up on the underlying technologies needed to support Web Services.

There are two fundamental roles when working with Web services:

Activity 1: Creating a Web Service

Create a simple web service to return the time of day

  1. Start up Visual Studio 2008, Use the File menu to create a New Web Site, choose ASP.NET Web Service and place it at U:\Day6\Day6WS
  2. The Web Service project contains a Service.asmx file and a corresponding C# code behind file
  3. Refactor the HelloWorld method by by renaming it GetTime
  4. Modify this new GetTime method to return the current time as a string
    • return DateTime.Now.ToShortTimeString();
  5. Build your Web service to remove any compiler errors
  6. To test your Web service, right-click your Service.asmx file and select View in Browser

Activity 2: Consuming a Web Service

Add a Web site to your solution to consume your simple service

  1. From the file menu, select Add >> New Web Site to add a ASP.NET Web Site and place it at U:\Day6\Day6WebSite in your current solution
  2. Right click on the Day6WebSite web site project and Add Web Reference to your project
    • Choose "Web services in this solution"
    • Select the Service Web service
    • Click Add Reference button
  3. Open the default.aspx page and add a button and a label to the page
  4. Generate a button click event handler that assigns the label's Text property to the value returned by you an instantiated TimeOfDay object's GetTime() method

Consuming Web Services from the Web

Normally one is expected to pay for a Web service. However, there are a number of free Web services provided by the Web that we can use to practice using a external Web service.

Activity 3: Consuming a free web service over the Web

  1. Use a brower to go to WebserviceX.NET
  2. Find an interesting Web service and test it in your browser
  3. Add a Web Reference to this Web service in your Day 6 project
  4. Construct a user-interface aspx page to test this Web service

TerraService is another popular free Web service is available at http://terraserver-usa.com/TerraService2.asmx

| Return to top | | Site Management | Find Broken Links | edit | attr | Documentation Index | PmWiki.org |

Page last modified on April 03, 2008, at 11:25 AM