RAD Studio for Microsoft .NET |  |

Building an ASP.NET "Hello World" Web Services Application
See Also
Collapse All

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.

To create a simple "Hello World" application with ASP.NET Web Services

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 ASP.NET Web Services application

1. Choose FileNewOther. A New Items dialog box appears.
2. Select the ASP Projects folder for the language you are using.
3. Select ASP.NET Web Service Application. An Application Name dialog box 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.pas or WebService.asmx.cs 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 WebMethods in the code-behind file. Delphi for .NET applications have two "Hello World" WebMethods to uncomment; one in the Interface module and the other 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:

Copy Code

    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.

1. Test the two methods from a web browser.

See Also

ASP.NET Web Services Overview

ASP.NET Web Services Support

Accessing an ASP.NET "Hello World" Web Services Application

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