RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Porting a Delphi for Win32 Web Service Client Application to Delphi for .NET

The following steps are required to port your Delphi for Win32 Web Services client application to Delphi for .NET.

To port your web service

  1. Change the existing RIO form components.
  2. Change the uses clause.
  3. Add a web reference.
  4. Change the web service invocation code.

To change your existing form components

  1. Copy and save the web reference URL from your existing RIO component.
  2. Delete the HTTPRio component from the form if it was not dynamically created.

To change the uses clause

  1. Remove any Delphi for Win32 SOAP units from the clause. These include, but are not restricted to InvokeRegistry, RIO, and SOAPHTTPClient.
    Warning: The preceding list of units is not inclusive. Make sure you identify all SOAP units, regardless of naming convention. Not all of the units include the word SOAP in the name.
  2. Remove the reference to the Delphi for Win32 WSDL Importer-generated Interface proxy unit.
  3. Remove the proxy unit from the project.

To add a web reference

  1. Open a Delphi for Win32 project in RAD Studio and choose ProjectAdd Web Reference. Once you have saved the project, the UDDI Browser appears.
  2. Enter the URL you want to use, either a service you are already familiar with, or the one saved from your RIO component into the list box at the top of the Browser.
    Note: If you want to locate a WSDL file on your local disk, you can click the ellipsis button next to the list box and search for the document. You can also navigate to one of the web service sites listed in the UDDI Browser if you want to use a published service.
  3. Click the Add Reference button to add the WSDL document to your project. RAD Studio creates the necessary web reference and the corresponding proxy unit based on the WSDL document. A new Web References node appears in the Project Manager. Expand it to see the associated WSDL and proxy code files.
  4. Choose FileUse Unit.

To change the web service invocation code

  1. In the code file for your application, locate the code that invokes the web service. Assume it looks something like this:

procedure TForm1.Button1Click(Sender: TObject);
var
HelloService: Service3Soap;
begin

// The next line will be slightly different if you have 
// used a component or generated the method dynamically.

 // This is how it will look if you used a component.
HelloService := (HTTPRIO1 as Service3Soap);

// This is how it will look if created dynamically. 
// GetService3Soap is the global method in the proxy unit.
 HelloService := GetService3Soap; 
 
Caption := HelloService.HelloWorld;
end;

  1. Change the var section from this:

var
// This is the type of the old proxy interface.
HelloService: Service3Soap;  

to

var
// This is the type of the new proxy class.
HelloService: Service3;  

This assumes the name of your service is Service3. Change the name accordingly.

Note: You will see that what was formerly created as an interface is now created as a class. The .NET Framework provides automatic garbage collection, and so certain restrictions placed on the use of classes in previous versions of Delphi may no longer apply when using RAD Studio.
  1. Change the first line in the procedure block from this:

HelloService := (HTTPRIO1 as Service3Soap);

to:

HelloService := Service3.Create;

The updated code should look like this:

procedure TForm1.Button1Click(Sender: TObject);
var
HelloService: Service3;
begin
HelloService := Service3.Create;
Caption := HelloService.HelloWorld;
end;

Your code is most likely more complex than this example. However, these instructions cover the basic steps for porting any Delphi for Win32 application that uses web services to RAD Studio.

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