使用 Python/Suds 在名称中使用点调用 SOAP 方法

kfe*_*fed 2 python soap suds

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

泡沫文档描述了方法调用是这样的:

client.service.Company.GetQueue()

但我从这一切的变化中得到的只是:

suds.MethodNotFound:找不到方法:'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, )
Run Code Online (Sandbox Code Playgroud)

Fli*_*McF 5

kfed 是对的,它是做它的点。但我不想改变我的 WSDL。

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

Company_GetTokenCount = getattr(client.service, 'Company.GetTokenCount')
Company_GetTokenCount()
Run Code Online (Sandbox Code Playgroud)

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