Tuesday, September 06, 2005

Access Violation when importing Amazon Webservice WSDL

When importing the WebService interface from Amazon into Delphi 7/2005 you'll get an access violation. While this is not the only WSDL with that problem, this is probably the most well known one.

The problem lies in the Delphi WSDL importer, which cannot distinguish inlined complex types, such as 'items' in 'CartAddRequest'. The problem is in the logic that maps a named array (in this case 'items') to a class. That logic must be enabled for the top level type but not for the nested ones. Unfortunately, Delphi doesn't distinguish between the two and enables it for the nested one as well. You should be able to avoid the AV by turning off that mapping (i.e. by using the -Ok- command line switch).

However, the code generated will not work in cases where you need to access an serialized array with a specified name, since Pascal and C++ don't
provide for a way to associate a type name with an array (syntactically they
do but that information is not kept in the compiler's typeinfo about the
type) the array element name will be serialized with the wrong name.

Now, it is possible that the code generated might work for you if you are not using some operations that involve named array types.

Thanks to Jean-Marie Babet for pointing that out.


Post a Comment

<< Home

Search WWW Search delphi-notes.blogspot.com