-
Notifications
You must be signed in to change notification settings - Fork 0
/
EyeFiSOAPMessages.py
171 lines (120 loc) · 6.91 KB
/
EyeFiSOAPMessages.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import xml.sax
from xml.sax.handler import ContentHandler
import xml.dom.minidom
class EyeFiSOAPMessages():
def getUploadPhotoXML(self, fileid, macaddress, filename, filesize, filesignature, encryption):
doc = xml.dom.minidom.Document()
SOAPElement = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/","SOAP-ENV:Envelope")
SOAPElement.setAttribute("xmlns:SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/")
SOAPElement.setAttribute("xmlns:ns1","EyeFi/SOAP/EyeFilm")
SOAPBodyElement = doc.createElement("SOAP-ENV:Body")
uploadPhotoElement = doc.createElement("ns1:UploadPhoto")
fileidElement = doc.createElement("fileid")
fileidElementText = doc.createTextNode(str(fileid))
fileidElement.appendChild(fileidElementText)
macaddressElement = doc.createElement("macaddress")
macaddressElementText = doc.createTextNode(str(macaddress))
macaddressElement.appendChild(macaddressElementText)
filenameElement = doc.createElement("filename")
filenameElementText = doc.createTextNode(str(filename))
filenameElement.appendChild(filenameElementText)
filesizeElement = doc.createElement("filesize")
filesizeElementText = doc.createTextNode(str(filesize))
filesizeElement.appendChild(filesizeElementText)
filesignatureElement = doc.createElement("filesignature")
filesignatureElementText = doc.createTextNode(str(filesignature))
filesignatureElement.appendChild(filesignatureElementText)
encryptionElement = doc.createElement("encryption")
encryptionElementText = doc.createTextNode(str(encryption))
encryptionElement.appendChild(encryptionElementText)
uploadPhotoElement.appendChild(fileidElement)
uploadPhotoElement.appendChild(macaddressElement)
uploadPhotoElement.appendChild(filenameElement)
uploadPhotoElement.appendChild(filesizeElement)
uploadPhotoElement.appendChild(filesignatureElement)
uploadPhotoElement.appendChild(encryptionElement)
SOAPBodyElement.appendChild(uploadPhotoElement)
SOAPElement.appendChild(SOAPBodyElement)
doc.appendChild(SOAPElement)
return doc.toxml(encoding="UTF-8")
def getStartSessionXML(self, macaddress, cnonce, transfermode, transfermodetimestamp):
doc = xml.dom.minidom.Document()
SOAPElement = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/","SOAP-ENV:Envelope")
SOAPElement.setAttribute("xmlns:SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/")
SOAPBodyElement = doc.createElement("SOAP-ENV:Body")
startSessionElement = doc.createElement("StartSession")
startSessionElement.setAttribute("xmlns","EyeFi/SOAP/EyeFilm")
macaddressElement = doc.createElement("macaddress")
macaddressElementText = doc.createTextNode(str(macaddress))
macaddressElement.appendChild(macaddressElementText)
cnonceElement = doc.createElement("cnonce")
cnonceElementText = doc.createTextNode(str(cnonce))
cnonceElement.appendChild(cnonceElementText)
transfermodeElement = doc.createElement("transfermode")
transfermodeElementText = doc.createTextNode(str(transfermode))
transfermodeElement.appendChild(transfermodeElementText)
transfermodetimestampElement = doc.createElement("transfermodetimestamp")
transfermodetimestampElementText = doc.createTextNode(str(transfermodetimestamp))
transfermodetimestampElement.appendChild(transfermodetimestampElementText)
startSessionElement.appendChild(macaddressElement)
startSessionElement.appendChild(cnonceElement)
startSessionElement.appendChild(transfermodeElement)
startSessionElement.appendChild(transfermodetimestampElement)
SOAPBodyElement.appendChild(startSessionElement)
SOAPElement.appendChild(SOAPBodyElement)
doc.appendChild(SOAPElement)
return doc.toxml(encoding="UTF-8")
def getPhotoStatusXML(self, credential, macaddress, filename, filesize, filesignature ):
doc = xml.dom.minidom.Document()
SOAPElement = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/","SOAP-ENV:Envelope")
SOAPElement.setAttribute("xmlns:SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/")
SOAPElement.setAttribute("xmlns:ns1","EyeFi/SOAP/EyeFilm")
SOAPBodyElement = doc.createElement("SOAP-ENV:Body")
getPhotoStatusElement = doc.createElement("ns1:GetPhotoStatus")
credentialElement = doc.createElement("credential")
credentialElementText = doc.createTextNode(str(credential))
credentialElement.appendChild(credentialElementText)
macaddressElement = doc.createElement("macaddress")
macaddressElementText = doc.createTextNode(str(macaddress))
macaddressElement.appendChild(macaddressElementText)
filenameElement = doc.createElement("filename")
filenameElementText = doc.createTextNode(str(filename))
filenameElement.appendChild(filenameElementText)
filesizeElement = doc.createElement("filesize")
filesizeElementText = doc.createTextNode(str(filesize))
filesizeElement.appendChild(filesizeElementText)
filesignatureElement = doc.createElement("filesignature")
filesignatureElementText = doc.createTextNode(str(filesignature))
filesignatureElement.appendChild(filesignatureElementText)
getPhotoStatusElement.appendChild(credentialElement)
getPhotoStatusElement.appendChild(macaddressElement)
getPhotoStatusElement.appendChild(filenameElement)
getPhotoStatusElement.appendChild(filesizeElement)
getPhotoStatusElement.appendChild(filesignatureElement)
SOAPBodyElement.appendChild(getPhotoStatusElement)
SOAPElement.appendChild(SOAPBodyElement)
doc.appendChild(SOAPElement)
return doc.toxml(encoding="UTF-8")
def getSOAPFaultXML(self, faultvalue, faulttext):
doc = xml.dom.minidom.Document()
SOAPElement = doc.createElementNS("http://schemas.xmlsoap.org/soap/envelope/","SOAP-ENV:Envelope")
SOAPElement.setAttribute("xmlns:SOAP-ENV","http://schemas.xmlsoap.org/soap/envelope/")
SOAPBodyElement = doc.createElement("SOAP-ENV:Body")
SOAPFaultElement = doc.createElement("SOAP-ENV:Fault")
codeElement = doc.createElement("SOAP-ENV:Code")
valueElement = doc.createElement("SOAP-ENV:Value")
valueElementText = doc.createTextNode(str(faultvalue))
valueElement.appendChild(valueElementText)
reasonElement = doc.createElement("SOAP-ENV:Reason")
faulttextElement = doc.createElement("SOAP-ENV:Text")
faulttextElement.setAttribute("xml:lang","en-US")
faulttextElementText = doc.createTextNode(str(faulttext))
faulttextElement.appendChild(faulttextElementText)
codeElement.appendChild(valueElement)
reasonElement.appendChild(faulttextElement)
SOAPFaultElement.appendChild(codeElement)
SOAPFaultElement.appendChild(reasonElement)
SOAPBodyElement.appendChild(SOAPFaultElement)
SOAPElement.appendChild(SOAPBodyElement)
doc.appendChild(SOAPElement)
return doc.toxml(encoding="UTF-8")