forked from JMathiszig-Lee/GPconnect
-
Notifications
You must be signed in to change notification settings - Fork 1
/
parsesoap.py
67 lines (61 loc) · 2.1 KB
/
parsesoap.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pprint
from xml.etree import ElementTree
import requests
import xmltodict
with open("xml/2. Perform XCA ITI-38 query.xml") as iti38:
print("ITI38 query")
print("-" * 20)
dom = ElementTree.parse(iti38)
root = dom.getroot()
body = ElementTree.tostring(root)
headers = {"Content-Type": "application/xml"}
url = "http://127.0.0.1:8000/SOAP/iti38"
r = requests.post(url, data=body, headers=headers)
print(r.status_code)
print(r.text)
print("-" * 20)
# with open("xml/3. Return XCA ITI-38 query response.xml") as iti38:
# print("ITI38 response")
# print("-" * 20)
# dom = ElementTree.parse(iti38)
# root = dom.getroot()
# xmldict = xmltodict.parse(
# ElementTree.tostring(root),
# process_namespaces=True,
# namespaces={
# "http://www.w3.org/2003/05/soap-envelope": None,
# "http://www.w3.org/2005/08/addressing": None,
# "urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0": None,
# "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0": None,
# },
# )
# # pprint.pprint(xmldict)
# query = xmldict["Envelope"]
# pprint.pprint(query)
# print("-" * 20)
with open("xml/4. Perform XCA ITI-39 document retrieve.xml") as iti38:
print("ITI39")
print("-" * 20)
dom = ElementTree.parse(iti38)
root = dom.getroot()
xmldict = xmltodict.parse(
ElementTree.tostring(root),
process_namespaces=True,
namespaces={
"http://www.w3.org/2003/05/soap-envelope": None,
"http://www.w3.org/2005/08/addressing": None,
"urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0": None,
"urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0": None,
"urn:ihe:iti:xds-b:2007": None,
},
)
# pprint.pprint(xmldict)
query = xmldict["Envelope"]
# pprint.pprint(query)
print("-" * 20)
body = ElementTree.tostring(root)
headers = {"Content-Type": "application/xml"}
url = "http://127.0.0.1:8000/SOAP/iti39"
r = requests.post(url, data=body, headers=headers)
print(r.status_code)
# print(r.text)