RAD Studio
ContentsIndex
PreviousUpNext
Accessing an ASP.NET "HelloWorld" Web Services Application

If you want to consume the Web Services application you created, you must create a client application to access your ASP.NET Web Services application. This process requires different development steps to achieve the desired output. 

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

  1. Create a client application.
  2. Add a Web Reference for an XML Web Service.
  3. Create the code-behind logic.
  4. Select a name for your project and click OK. A WinForm1.cs TWinForm1.pas file is generated.

To create a client application

  1. Choose FileNewOther. A New Items dialog appears.
  2. Select any type of application to create your client, such as a RAD Studio application or an ASP.NET Web application. For this example, we will create a RAD Studio application using a Windows Form.
  3. Click OK. A New Project dialog appears.

To add a Web Reference for an ASP.NET Web Services application

  1. Choose ProjectAdd Web Reference.
  2. From the CodeGear C#Builder Universal UDDI Browser CodeGear Delphi for .NET Universal UDDI Browser web dialog, enter the following URL: http://localhost/WebService1/WebService1.asmx in the address text box at the top of the dialog.
    Note: The name of your application may differ from WebService1, as noted. In that case, use your own application name in place of WebService1 in the example preceding example.
  3. Press the Enter key.
    Note: If you need to determine the proper path and you are using IIS, you can open the IIS Administrator from the Windows XP Control Panel Administrative Tools. Find the WebService you have saved and compiled in the list of IIS web sites, then review the name of the site and the name of the .asmx file.
    If you've entered the proper path, this should display information about the WebMethods.
  4. Click the Service Description link to view the WSDL document.
  5. Click Add Reference to add the WSDL document to the client application. A Web References folder is added to the Project directory in the Project Manager which contains the WebService1.wsdl file and the dialog disappears.

To create the code-behind logic

  1. Add a button to the Windows Form.
  2. Double-click the button to view the code-behind file.
  3. Create a button event by typing the following in the Code Editor:

    private void button1_Click(object sender, System.EventArgs e)
        {
                WebService1 ws = new WebService1();
                button1.Text = ws.HelloWorld();
        }
procedure TWinForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
begin
               new ws := WebService1();
               button1.Text := ws.HelloWorld();
end;
To run the client application

  1. Save the application.
  2. Compile and run the project.
  3. Click the button. The "HelloWorld" caption appears on the button.

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