How to access .Net web service from Delphi Win32 application?

What options do I have if I want to enable the Delphi Win32 application to use the .NET web service?

Is it possible to interact directly? Or do I need to resort to intermediary software that communicates with a Delphi application on COM, for example?

The Delphi application in question is written in Delphi 2006, but it is planned to upgrade to Delphi XE soon.

+4
source share
3 answers

While your project is open in Delphi, follow the link:

File | New | Other ... | Delphi Projects | WebServices | Importer WSDL

Now the WSDL Importer Wizard will begin. Enter the WSDL address for your web service and click Next. It will show you various WSDL processing options. If necessary, you can change the settings. In the end, when the wizard is complete, you will have a new block in your project that contains the client-side shell classes and interfaces for your web service. Now you can use this class in different ways. The easiest way is to call a function called Get (Your_WebService_Name). For example, if your web service name is TestWebService, the function will be called GetTestWebService.

The function will return an interface, which is the same interface as your web service, now you can call the methods of this interface and it automatically passes the request to the remote server and returns the result back to you. A sample source code might look like this:

var MyTestService: ITestService; begin MyTestService := GetTestService(); MyTestService.TestMethod; end; 

Another option is that you manually configure the THttpRio object and use it. In fact, this is what the Get (Your_WebService_Name) function does inside.

+12
source

This does not work with C # web service, period. The Delphi client does not understand the C # header and vice versa.

+1
source

Just add the line InvRegistry.RegisterInvokeOptions(TypeInfo(xxx), ioDocument); to your initialization section of the generated imported file. It will work like a charm.
NOTE. Xxx must be replaced with the name of the imported web service.

+1
source

All Articles