<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
        xmlns="http://www.entaxy.ru/ExchangeTypes/1.0"
        xmlns:tns="http://www.entaxy.ru/ExchangeTypes/1.0"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"

        elementFormDefault="qualified"
        targetNamespace="http://www.entaxy.ru/ExchangeTypes/1.0">

    <xsd:element name="uuids" type="tns:TUUIDs"/>
    <xsd:element name="packets" type="tns:TPackets"/>

    <xsd:element name="response" type="tns:TResponse"/>
    <xsd:element name="uuid" type="tns:TUUID"/>
    <xsd:element name="getPacketsRequest" type="tns:TGetPacketsRequest"/>

    <xsd:complexType name="TResponse">
        <xsd:sequence>
            <xsd:element name="status" type="xsd:string"/>
            <xsd:element ref="tns:packets" minOccurs="0"/>
            <xsd:element ref="tns:uuids" minOccurs="0"/>
            <!-- BigPacketsGoesHere -->
            <xsd:element name="bigPacketInfos" type="tns:TBigPacketInfos" minOccurs="0"/>
            <xsd:element name="bigPacketPart" type="tns:TBigPacketPart" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TGetPacketsRequest">
        <xsd:sequence>
            <xsd:element name="busUUID" type="tns:TUUID" minOccurs="0"/>
            <xsd:element name="destination" type="tns:TAddress" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="limitCount" type="xsd:integer" minOccurs="0"/>
            <xsd:element name="limitSize" type="xsd:integer" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TAddress">
        <xsd:sequence>
            <xsd:element name="id" type="xsd:string"/>
            <xsd:element name="type" type="xsd:string" minOccurs="0" default="system.name"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TUUIDs">
        <xsd:sequence>
            <xsd:element name="uuid" type="tns:TUUID" maxOccurs="unbounded" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:simpleType name="TUUID">
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="TPackets">
        <xsd:sequence>
            <xsd:element name="packet" type="tns:TPacket" maxOccurs="unbounded" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TPacket">
        <xsd:sequence>
            <xsd:element name="header" type="tns:THeader" minOccurs="0"/>
            <xsd:element name="message" type="tns:TMessage"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="THeader">
        <xsd:sequence>
            <xsd:element name="transportUUID" type="tns:TUUID" minOccurs="0"/>
            <xsd:element name="destination" type="tns:TAddress" maxOccurs="unbounded" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TMessage">
        <xsd:sequence>
            <xsd:element name="messageUUID" type="tns:TUUID"/>
            <xsd:element name="messageType" type="xsd:string" minOccurs="0"/>
            <xsd:element name="priority" type="xsd:integer" minOccurs="0" default="4"/>
            <xsd:element name="source" type="tns:TAddress" minOccurs="0"/>
            <xsd:element name="customHeader" type="tns:TCustomHeader" maxOccurs="unbounded" minOccurs="0"/>
            <xsd:element name="contentType" type="xsd:string" minOccurs="0" default="application/xml"/>
            <xsd:element name="content" type="xsd:anyType" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TCustomHeader">
        <xsd:sequence>
            <xsd:element name="id" type="xsd:string"/>
            <xsd:element name="type" type="xsd:string" minOccurs="0"/>
            <xsd:element name="value" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>

    <!-- BigPacketsGoesHere -->

    <xsd:element name="bigPacketInfo" type="tns:TBigPacketInfo"/>
    <xsd:element name="bigPacketPart" type="tns:TBigPacketPart"/>
    <xsd:element name="getBigPacketPartRequest" type="tns:TGetBigPacketPartRequest"/>

    <xsd:complexType name="TBigPacketInfo">
        <xsd:sequence>
            <xsd:element name="messageUUID" type="tns:TUUID"/>
            <xsd:element name="partsCount" type="xsd:int"/>
            <xsd:element name="checksum" type="xsd:string"/>
            <xsd:element name="size" type="xsd:long"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TBigPacketInfos">
        <xsd:sequence>
            <xsd:element name="bigPacketInfo" type="tns:TBigPacketInfo" maxOccurs="unbounded" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TBigPacketPart">
        <xsd:sequence>
            <xsd:element name="messageUUID" type="tns:TUUID"/>
            <xsd:element name="part" type="xsd:int"/>
            <xsd:element name="data" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TGetBigPacketPartRequest">
        <xsd:sequence>
            <xsd:element name="messageUUID" type="tns:TUUID"/>
            <xsd:element name="part" type="xsd:int"/>
        </xsd:sequence>
    </xsd:complexType>

</xsd:schema>
