python开发笔记-python调用webservice接口

环境描述:

     操作系统版本:

root@9deba54adab7:/# uname -a
Linux 9deba54adab7 4.4.0-105-generic #128-Ubuntu SMP Thu Dec 14 12:42:11 UTC 2017 x86_64 GNU/Linux
root@9deba54adab7:/# 
root@9deba54adab7:/# more /etc/issue
Debian GNU/Linux 8 \n \l

    python环境:

root@9deba54adab7:/# pip
pip   pip2  
root@9deba54adab7:/# pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)
root@9deba54adab7:/# python
Python 2.7.9 (default, Sep 25 2018, 20:42:16) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

场景描述:

    python开发环境下,访问webservice接口,需要借助包suds;直接pip install suds 可能会出现报错“No module named client”

    这里整理了,离线断网环境下,安装suds包,小伙伴们如果遇到上述类似异常,可以参考。

首先到该地址下载:https://bitbucket.org/jurko/suds/downloads/?tab=downloads

点击如下图:Download repository

PS:本文操作时,所使用版本为:jurko-suds-94664ddd46a6.zip 

 将安装包上传到服务器,解压后,进入目录:jurko-suds-94664ddd46a6

执行安装:python setup.py install

安装完成,测试是否可以使用:

进入python环境,执行如下操作

from suds.client import Client
send_dic = {
'bFile':'test 89489234892849284982',
'fileName': 'test_file_name',
'channelName': 'test001'
}
url = "http://www.xxx.com/test/test001.svc?wsdl"
client = Client(url)
result = client.service.getPercentBodyFat(**send_dic)

print(result)

 

参考:

https://www.cnblogs.com/punkrocker/p/4082586.html

https://bitbucket.org/jurko/suds/downloads/

https://www.iteye.com/blog/ully-1266320

 

posted @ 2019-10-22 16:43  hello-Jesson  阅读(1869)  评论(0编辑  收藏  举报