Known .NET bugs when importing WSDLs

Note: This document is based on importing WSDLs in Visual Studio as a Web Reference, (Add > Service Reference… > Advanced… > Add Web Reference…)

Microsoft has some known bugs at the time of importing WSDLs, because of this it is likely that some errors may arise using .NET. This page lists known issues and how to address them. For all solutions, download the WSDL and all the related schemas (which is where most changes will be required).

1. xs:choice elements

Problem:

When looking at SOAP schemas, there are 2 kinds of elements that generate collections of objects, xs:choice and xs:sequence elements. However, xs:choice is not recognized by some .NET tools, causing these collections to not be generated.

Solution:

Perform a search & replace for all xs:choice elements and replace them with xs:sequence.

Example:

This is how it looks in the schema:

xs:choice example

This is how it should look after the change:

xs:complexType example

2. Nesting xs:attributeGroup references

Problem:

.NET does not have issues referencing xs:complexType elements, but it does for xs:attributeGroup. In scenarios where there’s a reference to an xs:attributeGroup and it has a reference to a different, nested xs:attributeGroup, the nested one will not be imported.

Solution:

Replace the xs:attributeGroup import with the actual content of that reference (recommendation: Do not remove the xs:attributeGroup definition, only the context with the reference, as it might be referenced somewhere else).

Example:

Taking the Bargain Finder Max API request as an example, inside </RequestorID> you are expected to have ID, but if the WSDL is imported without editing, then ID is not present.

This is how the element and attribute are expected to be specified in the request payload:

RequestorID example

Now, looking at the schema, we see that the RequestorID’s type is defined as UniqueID_Type:

RequestorID’s type as UniqueID_Type example

UniqueID_Type contains an xs:attributeGroup UniqueID_Group element referenced inside:

xs:attributeGroup example

Then, UniqueID_Group has another xs:attributeGroup referenced inside, ID_Group:

xs:attributeGroup example

And it is this reference (xs:attributeGroup), ID_Group, that is not captured by .NET, which is the one that defines the ID xs:attribute:

xs:attributeGroup example

3. Sequence + maxOccurs

Problem:

There are some scenarios where a method is expecting an object, but it gets a collection of these objects, so it fails when attempting to instantiate that class with an error like the one below, where is not expecting an array.

error: Cannot convert type

Solution:

Look for that element in the corresponding schema and remove the maxOccurs element, or replace “unbounded” with “1” or a specific number larger than 1.

Example:

This is how it looks in the schema:

xs:complexType unbounded example

This is how it should look after the change:

xs:complexType without unbounded example


Disclaimer: Sabre cannot take responsibility for providing schemas that consider all the known bugs for programming languages. Should you encounter additional issues with .NET or other programming languages / frameworks, we encourage you to share it with our developer community via StackOverflow. Sabre monitors the forum and provides support when needed.