RAD Studio
ContentsIndex
PreviousUpNext
Building an ASP.NET "Hello World" Web Services Application

Building an application with ASP.NET Web Services lets you expose functionality to your client application over a Web connection. These steps walk you through building a simple "Hello World" application with ASP.NET Web Services. Once built, the application exposes all of its objects and methods through a WebMethod that you create and access through a web browser.  

Creating a simple "Hello World" application with ASP.NET Web Services consists of three major steps:

  1. Create an ASP.NET Web Services application.
  2. Create a WebMethod.
  3. Test and run the ASP.NET Web Services application.
Note: Currently, using RAD Studio you can only create web services using the code-behind method. You cannot use the code inline method, in which you code your web service in the <ServiceName>.asmx file. Currently, RAD Studio does not support the code inline method of creating web services.

To create an an ASP.NET Web Services application

  1. Choose FileNewOther. A New Items dialog appears.
  2. Select the folder for the language you are using.
  3. Select ASP.NET Web Service Application. An Application Name dialog appears.
  4. Enter a name and location of the application in the fields and retain all other default settings.
    Note: If you are using the Cassini Web Server, you need to change the Location and Server entries. You also need to make sure you configure the Cassini Web Server before trying to run this application. Choose Tools->Options
    and select ASP.NET Options to set the Path and the Port for Cassini.
  5. Click OK. A WebService1.asmx file and a WebService1.asmx.<filetype>, are automatically created for you.

To create a WebMethod

  1. Select the WebService.asmx.cs WebService.asmx.pas tab at the bottom of the Code Editor . If you named your web service application something other than the default, that will be the name that appears on the tab. The code for the "Hello World" application is already included in the WebMethod that is created for you when you created the Web Services application.
  2. Uncomment the sample "HelloWorld"and "EchoString" WebMethods provided in the code-behind file. One of these is in the Interface module and the other is in the Implementation module.
  3. Choose ProjectBuild <project name> to build your project.
  4. Run your project. This invokes the browser which hosts the Web Service. The pages you see will include sample SOAP and HTTP code that you can use to access the WebMethods. You can run the samples and see how the results are passed to an output XML file.

To test and run the XML Web Service manually

  1. From a web browser, enter the location of the WebService1.asmx file on your localhost: http://localhost/WebService1/WebService1.asmx. The pages you see will include sample SOAP and HTTP code that you can use to access the WebMethods. You can run the samples and see how the results are passed to an output XML file.
    Note: You may need to use a slightly different syntax than that shown in this step. For instance, on some Windows XP machines, the localhost identifier should be your machine name. For instance, if you machine name is MyMachine, the syntax would be: http://MyMachine/WebService1/Webservice1.asmx.
  2. Test the two methods from a web browser.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!