簡體   English   中英

使用Python / Suds在名稱中使用點調用SOAP方法

[英]Calling SOAP Methods with dots in the name using Python/Suds

嘗試使用Python Suds進行SOAP調用。 它導入WSDL很好,它生成的客戶端看起來格式正確,但我無法訪問這些方法。

Suds文檔描述了這樣的方法調用:

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, )

kfed是對的,這是做它的點。 但我不想改變我的WSDL。

但是,我發現了這個解決方法:
使用getattr用字符串引用方法名稱,獲取方法的句柄,然后調用它:

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

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

啊哈。 看起來好像是“。” 在命名空間中,這在XML中是合適的,但是在Suds中存在問題。 我曾嘗試刪除,但Suds也緩存了WSDL。 這是逃脫的方法:

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

在頁面上下方是如何關閉緩存。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM