Skip to content

Instantly share code, notes, and snippets.

@ipconfiger
Created May 14, 2012 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipconfiger/2691436 to your computer and use it in GitHub Desktop.
Save ipconfiger/2691436 to your computer and use it in GitHub Desktop.
python调用WebService接口
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