forked from andaok/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonToSoapWS.py
More file actions
59 lines (43 loc) · 1.24 KB
/
PythonToSoapWS.py
File metadata and controls
59 lines (43 loc) · 1.24 KB
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
# -*- encoding:utf-8 -*-
'''
Created on Sep 8, 2012
@author: root
'''
'''
related module : httplib
intro : how to post a soap message with python
'''
import httplib
SM_TEMPLATE = """<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<ns1:info xmlns:ns1="http://phonedirlux.homeip.net/types">
<symbol>%s</symbol>
</ns1:info>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
"""
dict = {"NodeHostName":"terry1.cloudiya.com","age":102}
SoapMessage = SM_TEMPLATE%(dict)
try:
conn = httplib.HTTPS("c03.cloudiya.com:8443")
conn.putrequest("POST", "/wsrf/services/InfoServices?wsdl")
conn.putheader("Host","c03.cloudiya.com")
conn.putheader("User-Agent", "python test")
conn.putheader("Content-type", "text/xml;charset=\"UTF-8\"")
conn.putheader("Content-length", "%d"%len(SoapMessage))
conn.putheader("SOAPAction", "\"\"")
conn.endheaders()
conn.send(SoapMessage)
statuscode,statusmessage,header = conn.getreply()
print statuscode
print statusmessage
print header
print conn.getfile().read()
except:
print "fail"
else:
print "start"
print "end"