一、接口信息
获取电话归属地接口
http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl
二、代码
#接口性能测试脚本
from locust import HttpLocust,task,TaskSet
import requests
class UserBehavior(TaskSet):
@task
def test_soap_tel1(self):
url = '/webservices/MobileCodeWS.asmx'
headers = {"Content-Type": "application/soap+xml; charset=utf-8"}
data = '''<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://WebXml.com.cn/">
<soap:Header/>
<soap:Body>
<web:getMobileCodeInfo>
<!--Optional:-->
<web:mobileCode>18561317472</web:mobileCode>
<!--Optional:-->
<web:userID></web:userID>
</web:getMobileCodeInfo>
</soap:Body>
</soap:Envelope> '''
# 传入数据,发送请求
response = self.client.post(url, data=data, headers=headers).text
print(response)
# 查找字符串判断请求是否成功
class WebSiteUser(HttpLocust):
host = 'http://ws.webxml.com.cn'
task_set = UserBehavior
min_wait = 2000
max_wait = 5000
#执行测试
#右键open in termainl
#输入locust -f test_InterfaceV2.py