Skip to content

Incorrect handling of union types #260

Description

@smx-smx

Describe the bug
An incorrect package is generated when having 2 different requests with the same field name but different type.
This is the relevant WSDL snippet (redacted)

What happens is that a single Items class is generated for both RequestA and RequestB, having a field of type string[] (probably the last type encountered in the WSDL).
This makes it impossible to call RequestA due to the wrong type bindings.

<!-- request A -->
<xs:complexType name="RequestA">
	<xs:sequence>
		<!-- Here "Items" is a struct array -->
		<xs:element name="Items" type="ns2:Items"/>
	</xs:sequence>
</xs:complexType>

<!-- request B -->
<xs:complexType name="RequestB">
	<xs:sequence>
		<!-- Here "Items" is a string array -->
		<xs:element name="Items">
			<xs:complexType>
				<xs:sequence>
					<xs:element name="Item" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
				</xs:sequence>
			</xs:complexType>
		</xs:element>
	</xs:sequence>
</xs:complexType>

<!-- struct typedef -->
<xs:complexType name="Item">
	<xs:sequence>
		<xs:element name="A" type="xs:string"/>
		<xs:element name="B" type="xs:int"/>
		<xs:element name="C" type="xs:string"/>
		<xs:element name="D" type="xs:string"/>
	</xs:sequence>
</xs:complexType>

<!-- Item[] typedef -->
<xs:complexType name="Items">
	<xs:sequence>
		<xs:element name="Item" type="ns2:Item" maxOccurs="unbounded"/>
	</xs:sequence>
</xs:complexType>

To Reproduce
Steps to reproduce the behavior:

  • During the package generation? no/yes (package generates without errors, but incorrectly)
  • During the usage of the generated package? yes (validation error when adding Item[], string[] expected)

Expected behavior
Generate 2 different classes for the union type, one with a string[] field and another with Item[]

Additional context
Using wsdltophp/packagegenerator @ 5c8ee49

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions