How to convert xsd to cs with redundancies? (OTA XML Publication)

Viewed 596

I'm trying to create a SOAP 1.2 based C# / WCF interface, that is supposed to handle HTNG / OTA messages. (a communication standard for hotels)

The publication of this OTA standard can be found here: Open Travel Alliance - Specifications

This publication contains a bunch of .xsd files that define all the types that can be passed through such an interface. For example for transferring new reservations to a hotel / system, you can use the OTA_HotelResNotifRQ message, that can contain HotelReservations. The SOAP XML would look something like this:

<soapenv:Body>
  <OTA_HotelResNotifRQ EchoToken="1474033560.151702" TimeStamp="2016-09-16T06:46:00-08:00" Version="1.001" xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 NeedToGetThisPathFromIdeas/OTA_HotelResNotifRQ.xsd" ResStatus="Modify">
    <POS>
    ...
    </POS>
    <HotelReservations>
      <HotelReservation CreateDateTime="2015-11-15T10:39:01-08:00" ResStatus="Reserved" LastModifyDateTime="2016-09-16T06:46:00-08:00">
        <UniqueID Type="14" ID="133121274"/>
        <RoomStays>
          <RoomStay MarketCode="Other OTA" SourceOfBusiness="OTA">
          ...
          </RoomStay>
        </RoomStays>
      </HotelReservation>
    </HotelReservations>
  </OTA_HotelResNotifRQ>
</soapenv:Body>

The problem is that there are multiple messages, and therefore multiple .xsd definitions using the same elements / classes. For example, for the HotelReservations mentioned above all of the marked messages use it:

enter image description here

All these .xsd files define the same classes, like HotelReservation or RoomStay, etc. and there is an additional .xsd (the HotelReservation, that is not a RQ or an RS) that defines the types used in these messages. What I'm saying is that these schema definitions are very very redundant.

When I try to generate .cs classes from these files, either by using xsd.exe from .NET Framework, or WSCF.Blue I'm faced with all the types getting repeated, for example HotelReservationType is going to be defined by OTA_HotelResRQ.cs, and again by OTA.HotelResNotifRQ.cs, and again by etc. This of course leads to a useless code and to Visual Studio yelling "ambigious reference" all over the place like crazy.

How can I convert these .xsd definitions to .cs classes without redundancy, having all types defined only once? Is there a tool that can do this or did Open Travel Alliance really mess up their publications and I'm pretty much screwed?

1 Answers
Related