2012-02-29 90 views
0

我想詢問使用SUDS獲取Web服務的參數和屬性的WSDL。我非常喜歡這個最後一件事。如何詢問服務以查找參數的minOccurs和maxOccurs值?Python SUDS - 詢問WSDL的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] 

我怎樣才能找出一個參數綁定?

謝謝!

回答

0

您可以查詢該方法的工廠解析器,並使用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 

不是很優雅,但它的工作原理

相關問題