Consuming ASP.NET 2.0 Web Services in Delphi for Win32

2013 年 7 月 4 日5040

FROM:http://www.bobswart.nl/weblog/Blog.aspx?RootId=5:798

Acouple of years ago I wrote an article Consuming C# Web Services with Delphi 7 Professional, and while the information in the article is still correct, it's no longer complete, because ASP.NET 2.0 changed the rules a little bit.
Even if you follow the examples exactly on creating the web service in C# and in creating the consuming application in Delphi for Win32, no matter what you try to echo, the result will always come back as 0 for numbers or as an empty string for strings.

This is due to the fact that the C# web service is deployed on an ASP.NET 2.0 machine (which changed some of the ways WSDL was published compared to .NET 1.1).

The problem is caused by the fact that any .NET Web Service is using the document|literal binding. With ASP.NET 1.x Web Services, this was specified using element, but with ASP.NET 2.0 Microsoft has changed that and now specifies the style in the operation input and output nodes instead of the binding element. The Delphi Win32 WSDL Importer is not able to recognise this, and as a result the generated import unit is using the (for Delphi default) binding type of RPC instead of the .NET document|literal binding type.
CodeGear is aware of the situation, and is already working on fixing the problem in the Win32 WSDL Importer. In the meantime, there is a workaround available that you can use, namely manually specifying the ioDocument as InvokeOptions for the SOAP interface type, as follows:

InvRegistry.RegisterInvokeOptions(TypeInfo(xxx), ioDocument);

Where xxx is the name of your SOAP interface type.

This line of code needs to be added to the initialization section of the generated Win32 import unit, and will make sure the parameters and result types are no longer empty when Win32 clients are talking to ASP.NET 2.0 Web Services.

0

0

0

(请您对文章做出评价)

0 0