简体   繁体   English

Python SUDS-向WSDL查询MinOccurs和MaxOccurs值

[英]Python SUDS - Interrogating the WSDL for MinOccurs and MaxOccurs values

I would like to interrogate a WSDL using SUDS to get the parameters and attributes of a web service. 我想使用SUDS询问WSDL以获取Web服务的参数和属性。 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? 如何查询服务以查找参数的minOccurs和maxOccurs值?

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. 我看到suds.xsd.sxbase对象中有一个称为required的属性,但是,假设我的出发点是客户端对象,则看不到该属性的路径。

http://jortel.fedorapeople.org/suds/doc/suds.xsd.sxbase-pysrc.html#SchemaObject.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]

How can I find out if a parameter is bound? 如何确定参数是否绑定?

Thanks! 谢谢!

you can query the factory resolver for the method, and use the children() method to see its parameters. 您可以向工厂解析器查询该方法,并使用children()方法查看其参数。

example, for this method I have my wsdl: 例如,对于这种方法,我有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 不是很优雅,但是可以用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM