<?xml version="1.0" encoding="UTF-8"?>
<!-- ========================================================================
  FICTIONAL training artifact: the OLD SOAP interface of the National
  Vehicle Registry (predecessor of the REST v2 API). Illustrative snippet -
  shows what analysts meet when a partner still runs legacy integrations.
  Used in wiki chapter 04 ("WSDL at a glance").
  How to read it: start at <portType> (the operations), then follow the
  message parts down to the <xsd:element> definitions (the data).
========================================================================= -->
<definitions name="VehicleRegistryService"
    targetNamespace="http://vehreg.example/soap/v1"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://vehreg.example/soap/v1"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <!-- 1. DATA TYPES: the XML equivalent of "schemas" in OpenAPI -->
  <types>
    <xsd:schema targetNamespace="http://vehreg.example/soap/v1">

      <xsd:element name="GetVehicleDataRequest">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="RegNumber" type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

      <xsd:element name="GetVehicleDataResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="RegNumber"          type="xsd:string"/>
            <xsd:element name="VinCode"            type="xsd:string" minOccurs="0"/>
            <xsd:element name="Make"               type="xsd:string"/>
            <xsd:element name="Model"              type="xsd:string"/>
            <xsd:element name="FirstRegDate"       type="xsd:date"/>
            <xsd:element name="EngineCapacityCcm"  type="xsd:int"    minOccurs="0"/>
            <xsd:element name="FuelType"           type="tns:FuelTypeEnum"/>
            <xsd:element name="OwnerType"          type="xsd:string"/>
            <xsd:element name="InspectionValidTo"  type="xsd:date"   minOccurs="0"/>
            <xsd:element name="VehicleStatus"      type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

      <!-- enumeration: compare with the REST API's lowercase fuel_type values -->
      <xsd:simpleType name="FuelTypeEnum">
        <xsd:restriction base="xsd:string">
          <xsd:enumeration value="PETROL"/>
          <xsd:enumeration value="DIESEL"/>
          <xsd:enumeration value="ELECTRIC"/>
          <xsd:enumeration value="HYBRID"/>
          <xsd:enumeration value="GAS"/>
          <xsd:enumeration value="OTHER"/>
        </xsd:restriction>
      </xsd:simpleType>

      <xsd:element name="VehicleNotFoundFault">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="RegNumber" type="xsd:string"/>
            <xsd:element name="Message"   type="xsd:string"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

    </xsd:schema>
  </types>

  <!-- 2. MESSAGES: wrap the elements above -->
  <message name="GetVehicleDataInput">
    <part name="body" element="tns:GetVehicleDataRequest"/>
  </message>
  <message name="GetVehicleDataOutput">
    <part name="body" element="tns:GetVehicleDataResponse"/>
  </message>
  <message name="VehicleNotFoundMessage">
    <part name="fault" element="tns:VehicleNotFoundFault"/>
  </message>

  <!-- 3. PORT TYPE: the list of operations - START READING HERE -->
  <portType name="VehicleRegistryPortType">
    <operation name="GetVehicleData">
      <input  message="tns:GetVehicleDataInput"/>
      <output message="tns:GetVehicleDataOutput"/>
      <fault  name="VehicleNotFound" message="tns:VehicleNotFoundMessage"/>
    </operation>
  </portType>

  <!-- 4. BINDING + SERVICE: transport details and the endpoint URL -->
  <binding name="VehicleRegistryBinding" type="tns:VehicleRegistryPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="GetVehicleData">
      <soap:operation soapAction="http://vehreg.example/soap/v1/GetVehicleData"/>
      <input><soap:body use="literal"/></input>
      <output><soap:body use="literal"/></output>
      <fault name="VehicleNotFound"><soap:fault name="VehicleNotFound" use="literal"/></fault>
    </operation>
  </binding>

  <service name="VehicleRegistryService">
    <port name="VehicleRegistryPort" binding="tns:VehicleRegistryBinding">
      <soap:address location="https://soap.vehreg.example/v1/VehicleRegistryService"/>
    </port>
  </service>

</definitions>
