Calling SOAP Methods with dots in the name using Python/Suds
Trying to make a SOAP call using Python Suds. It imports the WSDL fine, and the client it generates looks well-formed, but I am unable to access the methods.
The Suds documentation describes the method calls like this:
client.service.Company.GetQueue()
But all I get with every variation of this is:
suds.MethodNotFound: Method not found: 'OmnitureWebService.OmnitureWebServicePort.Company'
Here's the variable dump of the client I have created. You can see the methods are there, but how do I access them? I've tried specifying the port, specifying prefixes, nothing seems to work. Thanks for any help with this.
> obj._ServiceSelector__c开发者_StackOverflow中文版lient = 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 is right, it's the dots that do it. but I don't want to alter my WSDL.
However, I found this workaround:
Use getattr to reference the method name with a string, get a handle to the method, then call it:
Company_GetTokenCount = getattr(client.service, 'Company.GetTokenCount')
Company_GetTokenCount()
https://fedorahosted.org/suds/ticket/253
Me: Suds version 0.4 GA build: R699-20100913
Aha. It looks as if the "." in the namespace, which is proper in XML, but has problems with Suds. I had tried removing, but Suds also caches the WSDL. Here's how to escape:
https://fedorahosted.org/suds/wiki/TipsAndTricks
And lower down on the page is how to turn off caching.
精彩评论