【问题标题】:Calling SOAP Methods with dots in the name using Python/Suds使用 Python/Suds 调用名称中带有点的 SOAP 方法
【发布时间】:2011-01-07 20:23:35
【问题描述】:

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

Suds documentation 是这样描述方法调用的:

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

【问题讨论】:

    标签: python soap suds


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 哇哇哇。这几天我一直在尝试这样做。很好的发现,感谢发帖
    • @JiminyCricket 谢谢。我希望 kfed 接受这个作为答案。我不确定在不编辑 WSDL 的情况下是否有更好的方法。
    【解决方案2】:

    啊哈。看起来好像是“。”在命名空间中,这在 XML 中是正确的,但在 Suds 中存在问题。我曾尝试删除,但 Suds 也会缓存 WSDL。逃生方法如下:

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

    页面下方是如何关闭缓存。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-20
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多