【问题标题】:Python SUDS - Interrogating the WSDL for MinOccurs and MaxOccurs valuesPython SUDS - 查询 WSDL 以获取 MinOccurs 和 MaxOccurs 值
【发布时间】:2012-02-29 14:10:10
【问题描述】:

我想使用 SUDS 查询 WSDL 以获取 Web 服务的参数和属性。我几乎只剩下最后一件事了。如何查询服务以查找参数的 minOccurs 和 maxOccurs 值?

我看到 suds.xsd.sxbase 对象中有一个名为 required 的属性,但是,假设我的起点是客户端对象,我看不到到达它的路径。

http://jortel.fedorapeople.org/suds/doc/suds.xsd.sxbase-pysrc.html#SchemaObject.required

client = Client(endpoint, username=username, password=password)
client.service[0][method]

如何判断参数是否绑定?

谢谢!

【问题讨论】:

    标签: python web-services wsdl port suds


    【解决方案1】:

    您可以在工厂解析器中查询该方法,并使用 children() 方法查看其参数。

    例如,对于这种方法,我有我的 wsdl:

    <complexType name="AddAuthorizationRoleRequestType">
       <sequence>
          <element name="_this" type="vim25:ManagedObjectReference" />
          <element name="name" type="xsd:string" />
          <element name="privIds" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
       </sequence>
    </complexType>
    

    我可以通过以下方式获取属性:

    >>> a=client.factory.resolver.find("ns0:AddAuthorizationRoleRequestType")
    >>> priv_el=a.children()[2][0]
    <Element:0x107591a10 name="privIds" type="(u'string', u'http://www.w3.org/2001/XMLSchema')" />
    >>> priv_el = a.children()[2][0]
    >>> priv_el.max
    unbounded
    >>> priv_el.min
    0
    

    不是很优雅,但很有效

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-13
      相关资源
      最近更新 更多