Created
May 14, 2012 02:29
-
-
Save ipconfiger/2691436 to your computer and use it in GitHub Desktop.
python调用WebService接口
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATALIST="""<?xml version="1.0" encoding="utf-8"?> | |
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> | |
<soap12:Body> | |
<GetDataListByDate xmlns="http://tempuri.org/"> | |
<token>%(token)s</token> | |
<fromDate>%(fdate)s</fromDate> | |
<toDate>%(tdate)s</toDate> | |
</GetDataListByDate> | |
</soap12:Body> | |
</soap12:Envelope>""" | |
def get_list_by_date(token,fromDate,toDate): | |
r=requests.post(HOST+'/api/StepDataService.asmx',data=DATALIST%dict(token=token,fdate=fromDate,tdate=toDate),headers = {'content-type': 'application/soap+xml','charset':'utf-8'}) | |
if r.status_code in [200,201,202,203]: | |
print r.text | |
else: | |
print r.status_code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment