I finally found out the cause of the Delphi WSDL Importer generating wrong .pas files when the WSDL file includes an XSD file that uses an xsd:group
(see below) at the top-level.
The resulting access violation was caused by forgetting a nil
check for a Context
(at the top-level it is nil
because there is no encompassing type yet; xsd:group
can be at the top-level).
There might also be other WSDL/XSD constructs leading to the same code path: a good set of WSDL/XSD combination would be needed for proper integration testing on this. Hopefully, Embarcadero has such a set.
Patches
All patches are at https://gist.github.com/jpluimers/2824c03ae816229a53ffa4830b2d6208. If you need a binary build that includes the patches, drop a comment below.
Before fixing, I had to get it building which required modifying the search path and output path (both see Delphi WSDL importer compiler defines). This is the first patch below (which results includes a huge .dproj
change as that’s what the IDE does to a project when you change just a few simple things).
The second patch below is the fix.
The fix is to replace if (TypeDef.IsAnonymous) then
by if (TypeDef.IsAnonymous) and Assigned(Context) then
in side the function TWSDLTypeImporter.AddComplexType
of WSDLImpWriter.pas
.
After careful checking of the group
handling (around etElementGroup
, cmGroupRef
, xtiElemGroup
, IXMLElementGroup
, IXMLElementGroups
), no other fixes are needed as the rest of the xsd:group
handling functions correctly at least for the WSDL/XSD combinations I had to import.
During fixing, I found some compiler defines would produce much more output. That output tremendously helped finding out if xsd:group
handling was indeed correct.
In the third patch, I have added another modification that introduces a new -logall
command-line parameter that enables all these in one go.
I have handed over the patches through internal channels in order to circumvent a long and tedious QC/QualityPortal process. Hopefully they will make it in the next major Delphi version.
Related
Patches generated by following the steps in [WayBack] Generate a git patch for a specific commit – Stack Overflow:
git format-patch -1 <<commit-SHA>>
Command-line parameters
The WSDLImp has many command-line parameters, some of which are not accessible from the IDE expert. More information on these at:
- 2007: [WayBack] Using the WSDL Importer
- 2009: [WayBack] WSDLIMP.EXE, the Command Line WSDL Import Tool
- Tokyo: [WayBack] WSDLIMP.EXE, the Command Line WSDL Import Tool – RAD Studio
xsd:group
An xsd:group
contains a group of definitions. It is similar to a list of fields in a record/class/interface in Delphi that you can use in multiple record/class/interface definitions. The group only has a name at the XSD level, but not at the Delphi generated code level: there the group is expanded in each place it is used.
More information: [WayBack] xsd – How to use the xml schema group element – Stack Overflow
–jeroen