Known .NET Bugs When Importing WSDLs
The following solutions should be applied when importing WSDLs into Visual Studio as a Web Reference.
Issue
Microsoft has some known bugs when importing WSDLs, and it's likely that some errors may result while using .NET. This page lists known issues and examples of how to address them. For all solutions, download the WSDL and all related schemas, which is where most changes will be required.
Tip: To import a WSDL in Visual Studio, go to: Add > Service Reference > Advanced > Add Web Reference.
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 reach out to our support teams and community forums.
Best practices
You should never feed-in WSDL URLs directly from Sabre Dev Studio into a production-level application. Always download all WSDL and common schema files locally. Contact our support team for workarounds, questions, and other best practices.
1. xs:choice
elements
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 find & replace for all instances of xs:choice
elements and replace with xs:sequence
.
Example
Here's an example before the change:
<xs:complexType> <xs:choice> <xs:element name="Errors" type="ErrorsType" minOccurs="0">
Here's an example after the change:
<xs:complexType> <xs:sequence> <xs:element name="Errors" type="ErrorsType" minOccurs="0">
2. Nesting xs:attributeGroup
references
.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
Using 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 the ID is not present.
Here is an example of how the element and attribute should be specified in the request payload:
<RequestorID ID="1" Type="1"> <CompanyName Code="TN"/> </RequestorID>
Looking at the schema, we see that the RequestorID’s type is defined as UniqueID_Type:
<xs:element name="RequestorID" type="UniqueID_Type"> <xs:annotation> <xs:documentation xml:lang="en">An identifier of the entity making the request (e.g. ATA/IATA/ID number, Electronic Reservation Service Provider (ERSP), Association of British Travel Agents (ABTA)). </xs:documentation> </xs:annotation> </xs:element>
UniqueID_Type contains an xs:attributeGroup
UniqueID_Group element referenced inside:
<xs:complexType name="UniqueID_Type"> <xs:annotation> <xs:documentation xml:lang="en">An identifier of the entity making the request (e.g. ATA/IATA/ID number, Electronic Reservation Service Provider (ERSP), Association of British Travel Agents (ABTA)). </xs:documentation> </xs:annotation> <xs:sequence> <xs:element name="CompanyName" type="CompanyNameType" minOccurs="0"> <xs:annotation> <xs:documentation xml:lang="en">Identifies the company that is associated with the UniqueID. </xs:documentation> </xs:annotation> </xs:element> </xs:sequence> <xs:attributeGroup ref="UniqueID_Group"> </xs:complexType>
Then, UniqueID_Group has another xs:attributeGroup
referenced inside, ID_Group:
<xs:attributeGroup name="UniqueID_Group"> <xs:attribute name="URL" type="xs:anyURI"> <xs:annotation> <xs:documentation xml:lang="en">URL that identifies the location associated with the record identified by the UniqueID.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="Type" type="OTA_CodeType" use="required"> <xs:annotation> <xs:documentation xml:lang="en">A reference to the type of object defined by the UniqueID element. Refer to the OTA Code List Unique ID Type (UIT). </xs:annotation> </xs:attribute> <xs:attribute name="Instance" type="StringLength1to32"> <xs:annotation> <xs:documentation xml:lang="en">The identification of a record as it exists at a point in time. An instance is used in update messages where the sender must assure the server that the update sent refers to the most recent modification level of the object being updated. </xs:documentation> </xs:annotation> </xs:attribute> <xs:attributeGroup ref="ID_Group"/> <xs:attribute name="ID_Context" type="StringLength1to32" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">Used to identify the source of the identifier (e.g. IATA, ABTA, etc.)</xs:documentation> </xs:annotation> </xs:attribute> </xs:attributeGroup> </pre>
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 name="ID_Group"> <xs:attribute name="ID" type="StringLength1to32" use="required"> <xs:annotation> <xs:documentation xml:lang="en">A unique identifying value assigned by the creating system. The ID attribute may be used to reference a primary-key value within a database or in a particular implementation.</xs:documentation> </xs:annotation> </xs:attribute> </xs:attributeGroup>
3. Sequence + maxOccurs
There may be 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.
Solution
Look for the element in the corresponding schema and remove the maxOccurs element, or replace “unbounded” with “1” or a specific number larger than 1.
Example
Here's an example of how it looks in the schema:
<xs:complexType> <xs:sequence> <xs:element name="AssociatedDataItem" minOccurs="0">
Here's an example of how it should look after the change:
<xs:complexType> <xs:sequence> <xs:element name="AssociatedDataItem" minOccurs="0">