Understanding XML API Communication in IATA NDC Using C#

Understanding XML API Communication in IATA NDC Using C#

 Introduction

In airline technology, different software systems need to communicate to exchange flight information, pricing details, and booking requests. IATA New Distribution Capability (NDC) uses XML-based messages to support communication between airlines and travel sellers.

For developers working on airline integrations, understanding XML API communication is an important starting point.

1. What Is XML in NDC?

XML (Extensible Markup Language) is a structured format used to exchange information between applications.

An NDC integration can use XML messages to communicate information such as:

  • Flight search requests
  • Available flight offers
  • Passenger information
  • Pricing details
  • Booking requests

XML makes it possible for different applications to exchange structured information using an agreed message format.

2. Example of an XML Flight Search Request

Consider a customer searching for a flight from Delhi to London.

A simplified XML example could look like this:

<FlightSearchRequest>
    <Origin>DEL</Origin>
    <Destination>LHR</Destination>
    <DepartureDate>2027-01-15</DepartureDate>
    <PassengerCount>1</PassengerCount>
</FlightSearchRequest>

This example illustrates the basic structure of a flight search request. Actual NDC messages follow specific schemas and message definitions.

3. How Does the API Process the Request?

A typical integration workflow involves these steps:

  1. The travel application collects the customer's search details.
  2. The backend creates an XML request.
  3. The application sends the request to the airline's NDC API.
  4. The airline processes the request.
  5. The airline returns an XML response.
  6. The application processes the response and displays available flights.

This communication generally happens over HTTP or HTTPS, depending on the provider's integration requirements.

4. Sending an XML Request Using C#

Developers can use HttpClient in ASP.NET Core to communicate with an external NDC API.

A simplified example:

using System.Text;
public class FlightSearchService
{
    private readonly HttpClient _httpClient;
    public FlightSearchService(HttpClient httpClient)
    {
        _httpClient = httpClient;
    }
    public async Task<string> SearchFlightsAsync()
    {
        string xmlRequest = """
        <FlightSearchRequest>
            <Origin>DEL</Origin>
            <Destination>LHR</Destination>
            <DepartureDate>2027-01-15</DepartureDate>
            <PassengerCount>1</PassengerCount>
        </FlightSearchRequest>
        """;
        using var content = new StringContent(
            xmlRequest,
            Encoding.UTF8,
            "application/xml");
        using var response = await _httpClient.PostAsync(
            "configured-ndc-endpoint",
            content);
        response.EnsureSuccessStatusCode();
        return await response.Content.ReadAsStringAsync();
    }
}

This example demonstrates the basic HTTP communication approach. A real NDC integration also requires the correct airline-specific XML schema, message headers, authentication, and endpoint configuration.

5. Processing the XML Response

After receiving the response, the application needs to extract relevant information.

For example, an airline response might contain:

  • Flight number
  • Departure and arrival airports
  • Flight timings
  • Fare information
  • Offer reference

Developers can use .NET libraries such as System.Xml.Linq to read XML responses.

Example:

using System.Xml.Linq;
string xmlResponse = """
<Flight>
    <FlightNumber>AI101</FlightNumber>
    <Origin>DEL</Origin>
    <Destination>LHR</Destination>
</Flight>
""";
XDocument document = XDocument.Parse(xmlResponse);
string? flightNumber =
    document.Root?.Element("FlightNumber")?.Value;
Console.WriteLine(flightNumber);

The output will be:

AI101

6. Important Considerations for Developers

When developing an NDC integration, consider the following:

  • XML Validation: Validate requests and responses against the applicable XML schemas.
  • Authentication: Implement the authentication mechanism required by the airline or aggregator.
  • Error Handling: Handle invalid requests, unavailable services, and API timeouts.
  • Logging: Maintain request correlation IDs to trace transactions.
  • Security: Avoid logging sensitive passenger and payment information.
  • Versioning: Ensure that the integration supports the NDC version required by the provider.

Conclusion

XML API communication is one of the fundamental technical concepts behind IATA NDC integrations. Using .NET and HttpClient, developers can build services that communicate with airline systems, send structured requests, and process XML responses.

Understanding this communication process provides a foundation for implementing more advanced NDC capabilities, including flight shopping, offer pricing, order creation, and booking management.

Technology stack: C#, ASP.NET Core Web API, HttpClient, XML, SQL Server.

Note: The XML payloads in this article are simplified educational examples, not production-ready IATA NDC messages.

Post a Comment

0 Comments