#!/usr/local/bin/tclsh8.5                                                                                                                                                                                                                                                     

package require SOAP
package require WS::Client 2.2
package require log

proc initializeLogging {debugmode} {
    ::log::lvChannelForall stderr
    foreach lev [::log::levels] { ::log::lvSuppress $lev 0 }
    ::log::lvSuppress debug [expr $debugmode == 0]
}

proc initializeSoap {} {
    global apiname

    set baseUri "https://www.airservicesaustralia.com/FIB/flight-info-service"
    set wsdl [::WS::Client::GetAndParseWsdl "$baseUri?wsdl"]
    set apiname [::WS::Client::LoadParsedWsdl $wsdl]
}

proc getFlights {template} {
    global apiname

    array set result [::WS::Client::DoCall $apiname get-flight-summary [list "get-flight-summary" [list template $template account "my-bogus-username" password "my-bogus-password"]]]
}

initializeLogging 1
initializeSoap

getFlights [list "state" [list "state" "COOR CONT HAND SUSP INHB"]]
exit 0