Python SUDS-询问WSDL中的MinOccurs和MaxOccurs值 [英] Python SUDS - Interrogating the WSDL for MinOccurs and MaxOccurs values

查看:170
本文介绍了Python SUDS-询问WSDL中的MinOccurs和MaxOccurs值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to interrogate a WSDL using SUDS to get the parameters and attributes of a web service. I'm pretty much down to this one last thing. How do I interrogate the service to find the minOccurs and maxOccurs values of the parameters?

我看到suds.xsd.sxbase对象中有一个名为required的属性,但是,假设我的出发点是客户端对象,则看不到该属性的路径.

I see there's a property in the suds.xsd.sxbase object called required, but, assuming my starting point is the client object, I don't see path to get to it.

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

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

如何确定参数是否绑定?

How can I find out if a parameter is bound?

谢谢!

推荐答案

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

you can query the factory resolver for the method, and use the children() method to see its parameters.

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

example, for this method I have my 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>

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

I can get the attributes via:

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

不是很优雅,但是可以用

not very elegant, but it works

这篇关于Python SUDS-询问WSDL中的MinOccurs和MaxOccurs值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆