suds调用webservice
一、安装
pip install suds
二、日志
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger(“suds.client”).setLevel(logging.DEBUG)
三、基本方法,创建client
3.1 通过wsdL的url创建一个client实例,获取服务 提供的方法(Methods )及 数量 和 数据类型(types)及 数量
from suds import Client
url="http:///www.thomas-bayer.com/axis2/services/BLZService?wsdl”
client = Client(url)
print client
返回如下:
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913
Service ( BLZService ) tns=”http://thomas-bayer.com/blz/”
Prefixes (1)
ns0 = “http://thomas-bayer.com/blz/”
Ports (2):
(BLZServiceSOAP11port_http)
Methods (1):
getBank(xs:string blz, )
Types (3):
detailsType
getBankResponseType
getBankType
(BLZServiceSOAP12port_http)
Methods (1):
getBank(xs:string blz, )
Types (3):
detailsType
getBankResponseType
getBankType
3.2 简单的的参数调用:
3.2.1 单个服务器端口的直接调用
result = client.service.getBack(‘ICBC’)
print result
3.2.2 多个服务器端口的:
1、不指定端口的同单个服务器端口直接调用,服务会通过默认的端口处理
2、选择一个端口指定为默认端口
client.set_options(prot ='BLZServiceSOAP11port_http')
3、带服务端口名称的方法:
result = client.service[‘BLZServiceSOAP11port_http’].getBank(‘ICBC’)
print result
4、带服务端口索引的方法:
result= client。service.[0].getBank('ICBC')
print result
3.2.3 多服务与多端口:(类似与多端口的二维情况)
1、不指定服务器和端口
2、设置默认的服务和端口:
client.set_potions(service=’serviceName’, port=’portName’)
3、带服务名称和端口名称:
client.service[‘serviceName’][‘portName’].method()
4、带服务索引和端口索引:
client.service[serviceIndex][portIndex].method()
3.3复杂的参数调用:
1、使用factory.create方法根据wsdl中的格式创建复杂对象(create complex objects )
例如:http://apisandbox.4pxtech.com:8090/OrderOnline/ws/OrderOnlineService.dll?wsdl 参考文件:fourpx.rar
中创建复杂对象:createOrderRequest
order = client.factory.create("createOrderRequest”)
然后向将order中写入需要的数据,必须的参数minOccurs="1",非必须参数:minOccurs="0"
将order传给需要createOrderRequest类型参数的方法
详细参考:https://fedorahosted.org/suds/wiki/Documentation#SERVICESWITHMULTIPLEPORTS 中的FACTORY方法说明
2、HEADERS(参照HEADERS方法)
client = client(url)
token = client.factory.create('AuthToken')
token.username = 'Elvis'
token.password = 'TheKing'
client.set_options(soapheaders=token)
3、COSTOM SOAP HEADERS(参照COSTOM SOAP HEADERS方法)
4、PLUGINS
suds调用webservice的更多相关文章
- Python使用suds调用webservice报错解决方法:AttributeError: 'Document' object has no attribute 'set'
使用python的suds包调用webservice服务接口,报错:AttributeError: 'Document' object has no attribute 'set' 调用服务接口代码: ...
- python suds 调用webservice 缓存
在linux系统中 如果webservice更新了字段 suds调用有可能缓存以前的字段或方法,对新的字段报找不到类型 TypeNotFound,或者对 新加的方法找不到该方法的错误. 当更新或添加w ...
- python使用suds调用webservice接口
最近做接口对接,遇到了.net开发的webservice接口,因为python第一次与webservice对接,连问带查,最后使用suds库来实现了 1.安装suds mac: sudo pip in ...
- python使用SUDS调用webservice
最近做接口对接,遇到了.net开发的webservice接口,因为python第一次与webservice对接,连问带查,最后使用suds库来实现了 1.安装suds mac: sudo pip in ...
- python使用suds来调用webservice
对于python仅作为客户端调用webservice的情况,推荐使用suds库来完成,比起zsi,soapy之类,它可以说是相当轻量级,使用非常方便. 安装suds建议使用easy_insall来做. ...
- Python调用Webservice
使用Python调用webservice 推荐使用 suds包 该包一般在Python2.x python3各种麻烦 略过 实例 import suds # webservice url url ...
- 一个简单的webservice的demo(下)winform异步调用webservice
绕了一大圈,又开始接触winform的项目来了,虽然很小吧.写一个winform的异步调用webservice的demo,还是简单的. 一个简单的Webservice的demo,简单模拟服务 一个简单 ...
- 调用webservice进行身份验证
因为同事说在调用webservice的时候会弹出身份验证的窗口,直接调用会返回401,原因是站点部署的时候设置了身份验证(账号名称自己配置).因而在调用的时候需要加入身份验证的凭证. 至于如何获取身份 ...
- java接口调用——webservice就是一个RPC而已
很多新手一听到接口就蒙逼,不知道接口是什么!其实接口就是RPC,通过远程访问别的程序提供的方法,然后获得该方法执行的接口,而不需要在本地执行该方法.就是本地方法调用的升级版而已,我明天会上一篇如何通过 ...
随机推荐
- 使用DB4o做一个.Net版的website(一)环境
一个机缘巧合之下,知道了DB4o这个数据库引擎,下载查看之后,被其方便.高效.以及便捷的管理方式锁折服. 故决定使用其做一个.NET版本的web站点,来巩固学到的知识,以及为后来人做一点点贡献. 首先 ...
- java变量和方法的覆盖和隐藏(翻译自Java Tutorials)
隐藏变量 在一个类里,如果一个变量的名字和父类的变量的名字一样,即使他们的类型不一样,那么在子类中,父类的同名变量无法直接通过变量名访问.但是,父类的同名变量可以通过super访问.一般来说,不推荐隐 ...
- phpcms v9 的表单向导功能的使用方法
本文主要介绍phpcms v9的表单向导功能是如何使用的,并副多个案例讲解: 先介绍一下v9 的表单向导如何使用 表单向导做的很实用,生成一个表单,常用的是把它作为一个留言板,或者在招聘栏目作为一个供 ...
- android:layout_gravity 和 android:gravity 的区别
gravity 这个英文单词是重心的意思,在这里就表示停靠位置的意思. android:layout_gravity 和 android:gravity 的区别 从名字上可以看到,android:gr ...
- 命令行子shell 括号 ()
子shell 控制变量 ansible-direc:~ # (export hello=world;echo $hello)worldansible-direc:~ # echo $hello ans ...
- JQuery html API支持解析执行Javascript脚本功能实现-代码分析
JQuery html用法(功能类似innerHTML) 开发中需要使用Ajax技术来更新页面局部区域, 使用的方法是ajax获取html代码段(字符串),然后将这个html代码段作为参数,传入目标D ...
- [Android Tips] 14. Using Proguard with Android without obfuscation
Option -dontobfuscate REF Using Proguard with Android without obfuscation
- .Net分布式架构(二):基于Redis的Session共享
一:Session简介 Session是什么呢?简单来说就是服务器给客户端的一个编号.当一台web服务器运行时,可能有若干个用户浏览正在运正在这台服务器上的网站.当每个用户首次与这台web服务器建立连 ...
- Number类型方法
//1.toString(); 转换成字符串 var s=123; console.log(typeof s.toString()); //string //2.toLocaleString() ...
- Leetcode: Delete Node in a BST
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Retur ...