python call webservices interfaces

# Python interface to call the webservice 
from suds.client Import Client
 Import json
 '' ' 
After the call when 1.http need to ignore ssl certificate authentication 
ssl._create_default_https_context = ssl.create_unverified_context 
' '' 
url = ' XXXXX ' 
Client = Client (url) 
the Data = } {
 # The queryTimeout WebServices service providing method 
res = client.service.queryTimeout (json.dumps (data) )
now_time = int(time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())))


python 测试接口
import json
import requests
requests.packages.urllib3.disable_warnings()

def get_test(url):
    v = requests.get(url, verify=False).text
    print json.loads(v)['msg'].encode('utf8').decode('utf8')

def post_test(url,task_id):
    data = {cccccccccccccccccccccc}
    res = requests.post(url, data, verify=False) ####取消https  验证 
    print res.text
    print json.loads(res.text)['MSG ' ] # Information
     Print json.loads (res.text) [ ' Status ' ] Status Code # 

#
 URL = ' ' 
get_test (URL) 


#
 URL = ' ' 
post_test (URL, ' 125h8 ' )

 

Guess you like

Origin www.cnblogs.com/nanyu/p/11453904.html