使用Python/Suds调用名称中带有点的SOAP方法

2024-09-28 01:32:07 发布

您现在位置:Python中文网/ 问答频道 /正文

尝试使用Python Suds进行SOAP调用。它很好地导入了WSDL,它生成的客户端看起来格式良好,但是我无法访问这些方法。在

Suds documentation描述了如下方法调用:

client.service.Company.GetQueue()

但是我得到的每一个变化都是:

suds.MethodNotFound: Method not found: 'OmnitureWebService.OmnitureWebServicePort.Company'

这是我创建的客户机的变量转储。你可以看到这些方法,但是我如何访问它们呢?我尝试过指定端口,指定前缀,但似乎没有任何效果。谢谢你的帮助。在

> obj._ServiceSelector__client =  Suds (
> https://fedorahosted.org/suds/ ) 
> version: 0.4 GA  build: R699-20100913
> 
> Service ( OmnitureWebService )
> tns="http://www.omniture.com/"   
> Prefixes (2)
>       ns0 = "http://schemas.xmlsoap.org/soap/encoding/"
>       ns1 = "http://www.omniture.com/"    Ports (1):
>       (OmnitureWebServicePort)
>          Methods (173):
>             CodeManager.DeleteCodeArchive(xs:int
> archive_id, )
>             CodeManager.GenerateCode(xs:string
> char_set, xs:string code_type, xs:int
> cookie_domain_periods, xs:string
> currency_code, xs:string rsid, xs:int
> secure, )
>             CodeManager.GetCodeArchives(int_array
> archive_id_list, xs:string
> binary_encoding, xs:int
> populate_code_items, )
>             CodeManager.SaveCodeArchive(xs:string
> archive_description, xs:int
> archive_id, xs:string archive_name,
> code_items code, )
>             Company.CancelQueueItem(xs:int qid, )
>             Company.DownloadProduct(productType
> productType, )
>             Company.GetEndpoint(xs:string company,
> )
>             Company.GetQueue()
>             Company.GetReportSuites(string_array
> rs_types, xs:string sp, )
>             Company.GetTokenCount()
>             Company.GetTokenUsage()
>             Company.GetTrackingServer(xs:string
> rsid, )
>             Company.ResetTokenCount(xs:string
> auth_key, )

Tags: 方法orgclientidhttpstringcodecompany
2条回答

啊哈。它看起来像是名称空间中的“.”,这在XML中是正确的,但是在Suds中有问题。我尝试过删除,但是Suds也缓存WSDL。以下是如何逃离:

https://fedorahosted.org/suds/wiki/TipsAndTricks

下面是如何关闭缓存。在

kfed是对的,是这些点造成的。但我不想改变我的WSDL。在

但是,我找到了一个解决办法:
使用getattr以字符串引用方法名称,获取方法的句柄,然后调用它:

Company_GetTokenCount = getattr(client.service, 'Company.GetTokenCount')
Company_GetTokenCount()

https://fedorahosted.org/suds/ticket/253
Me:Suds版本0.4 GA内部版本:R699-20100913

相关问题 更多 >

    热门问题