python 调用 webservice
来源:互联网 发布:mac book 用什么vpn 编辑:程序博客网 时间:2024/06/06 18:26
python 远程调用c++的webservice接口
from suds import WebFaultfrom suds.client import Client
def get_vrm_info(self): #url 要访问的接口 url = 'http://xxxx:6300/xxx/xxxsoap?wsdl' client = Client(url) <span style="color:#FF6666;">client.set_options(port='storeserviceSoap12')#如果用的是soap12 而不是soap则需要修改端口</span> #传递参数,简单的,直接传一个数据,复杂的,需要用接口文档中提供的参数类型定义一个变量 p = client.factory.create('QueryRecordInfo') p.cameraindexcode='00000001001310000002' <span style="color:#FF0000;">p.recordtype.unsignedInt=[1]</span> p.starttime='2015-03-13T17:06:04.000Z' p.endtime='2015-03-13T17:11:04.000Z' p.netzoneid='1' #print (client)#查看接口所有的函数和类型 #print client.last_received()#查看接口的返回值 #获取了webservice的值 get_info = client.service.SearchCameraRecord(p) #有时候可以用xml的方式直接处理返回值,但是有时候xml解析失败,需要处理文本 print (get_info.split('<SegmentCount>')[1]).split('</SegmentCount>')[0]
红色的部分说明一下,xml文档是节点嵌套的,可能比较多,这个时候就一层层写下去
<recordtype> <unsignedInt>unsignedInt</unsignedInt> <unsignedInt>unsignedInt</unsignedInt> </recordtype>
<span style="color:#FF0000;"> array_int = client.factory.create('ArrayOfUnsignedInt') array_int.unsignedInt = [1,]</span>
以后的问题:
返回值的读取,最好是直接xml,然后用xml访问节点即可,但是有的时候可能不行
0 0
- Python调用WebService
- python 调用 webservice
- python调用java webservice
- java调用python的webservice
- python使用suds调用webservice
- python使用suds调用webservice
- python使用SUDS调用webservice
- python使用suds调用webservice
- python技巧31[调用webservice]
- python远程调用webservice服务
- python使用suds调用webservice
- python使用suds来调用webservice
- python 调用webservice两种方式
- Python调用基于https协议的WebService
- python调用java编写的Webservice
- python仅作为客户端调用webservice
- python使用suds模块调用webservice
- python调用java编写的Webservice
- 完美解决Ubuntu下vi编辑器方向键变字母的问题
- django中使用ajax(post)进行异步请求
- 主键和外键
- Symbols From Another External Module
- Redis应用场景
- python 调用 webservice
- python httplib 模块
- 概率论--概率及性质
- 学习计划
- C# 通过WebService方式 IIS发布网站 上传文件到服务器
- 解决win8和8.1 64位版本下无法使用debug
- 【0001】【TCP链接和释放】
- 数据库设计原则
- 欢迎使用CSDN-markdown编辑器