Python 2.7 如何在Python中使用sud提取方法
我想提取所有的方法,并想使用how-can-do-automation发送一些参数 我只想要方法作为用户输入,并向方法发送参数。 我怎样才能做到这一点Python 2.7 如何在Python中使用sud提取方法,python-2.7,suds,Python 2.7,Suds,我想提取所有的方法,并想使用how-can-do-automation发送一些参数 我只想要方法作为用户输入,并向方法发送参数。 我怎样才能做到这一点 from suds.client import client url="name fo the url" client=Client(url) Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913 Service ( Services ) t
from suds.client import client
url="name fo the url"
client=Client(url)
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913
Service ( Services ) tns="http://www.altoromutual.com/bank/ws/"
Prefixes (1)
ns0 = "http://www.altoromutual.com/bank/ws/"
Ports (2):
(ServicesSoap)
Methods (3):
GetUserAccounts(xs:int UserId, )
IsValidUser(xs:string UserId, )
TransferBalance(MoneyTransfer transDetails, )
Types (4):
AccountData
ArrayOfAccountData
MoneyTransfer
Transaction
(ServicesSoap12)
Methods (3):
GetUserAccounts(xs:int UserId, )
IsValidUser(xs:string UserId, )
TransferBalance(MoneyTransfer transDetails, )
Types (4):
AccountData
ArrayOfAccountData
MoneyTransfer
Transaction
要列出WSDL中可用的所有方法,请执行以下操作:
>>> from suds.client import Client
>>> url_service = 'http://www.webservicex.net/globalweather.asmx?WSDL'
>>> client = Client(url_service)
>>> list_of_methods = [method for method in client.wsdl.services[0].ports[0].methods]
>>> print list_of_methods
[GetWeather, GetCitiesByCountry]
然后调用方法本身:
>>> response = client.service.GetCitiesByCountry(CountryName="France")
注:一些简单示例可在“”中找到
在@kflow的评论之后,下面是如何检索应传递给方法的参数列表:
>>> method = client.wsdl.services[0].ports[0].methods["GetCitiesByCountry"]
>>> params = method.binding.input.param_defs(method)
>>> print params
[(CountryName, <Element:0x10a574490 name="CountryName" type="(u'string', u'http://www.w3.org/2001/XMLSchema')" />)
>method=client.wsdl.services[0]。端口[0]。方法[“GetCitiesByCountry”]
>>>params=method.binding.input.param_defs(method)
>>>打印参数
[(国家名称,)
您如何知道传递给方法的值应采用何种格式,就像在您的示例中一样,您如何知道值的格式应为CountryName='France'而不仅仅是'France'?@kflaw我已经更新了我的答案,以检索名称和参数类型。谢谢!我还找到了temp=str(客户端);
给了我一些关于类型和所需内容的额外信息。不幸的是,我仍然感到困惑,认为我需要与开发该服务的人谈谈