-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_oag_soap.py
41 lines (34 loc) · 1.28 KB
/
test_oag_soap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import base64
from constants import *
import datetime
import pprint
import xmltodict
import zeep
#import log # uncomment to print debugging logs
pp = pprint.PrettyPrinter(indent=4)
if __name__ == "__main__":
client = zeep.Client(wsdl=OAG_WSDL, strict=False)
# set up header and login details
header = {"Host": "status.oag.com",
"Content-Type": "text/xml; charset=utf-8",
"SoapAction": ""}
client.transport.session.headers = header
logindetails = {"username": OAG_USERNAME, "password": OAG_PASSWORD}
with client.options(raw_response=True):
resp = client.service.getFlights({
"flightsQueryWSVO": {
"fromDate": datetime.datetime.strptime("2011-01-10", "%Y-%m-%d"),
"plusMinusaDay": True,
"airlineCode": "BA",
"depAptCode": "LHR",
"arrAptCode": "DEL"
},
"loginDetailsVO": logindetails
})
resp_dict = xmltodict.parse(resp.content)
flights = resp_dict["S:Envelope"]["S:Body"]["ns2:getFlightsResponse"]["return"]
for flight in flights:
print "Details for flight ID:", flight["id"]
for k, v in flight.iteritems():
print "\t", k, v