2011-05-11 225 views
4

如何使用「選擇」參數生成請求方法?在http://127.0.0.1/service?wsdl WSDL的泡沫和選擇標記

部分:

 
<xs:complexType name="ByA"> 
<xs:sequence> 
... 
</xs:sequence> 
</xs:complexType> 
<xs:complexType name="ByB"> 
<xs:sequence> 
... 
</xs:sequence> 
</xs:complexType> 

<xs:complexType name="GetMethodRequest"> 
<xs:choice> 
<xs:element name="byA" type="s0:ByA" /> 
<xs:element name="byB" type="s0:ByB" /> 
</xs:choice> 
</xs:complexType> 

當我做

 
from suds.client import Client 
client = Client("http://127.0.0.1/service?wsdl") 
print client 

我看到

GetMethod()

不帶任何參數。

我如何通過byA或byB調用GetMethod?

回答

0

很難知道沒有看到整個wsdl,你的鏈接是你的本地機器。

Suds客戶端類使用Service Class作爲實例變量與wsdl進行交互。你有沒有嘗試過這樣的事情?

 
from suds.client import Client 
client = Client("http://127.0.0.1/service?wsdl") 
client.service.GetMethod("byA") 

client.service.GetMethod("byB")

+0

不起作用 肥皂體是空的 – 2011-05-11 13:02:48

+0

再次,不確定沒有看到wsdl。我描述的方法是suds如何在Web服務上調用方法。 – supersighs 2011-05-11 13:08:18

+0

我知道如何調用泡沫方法,我不明白爲什麼泡沫沒有顯示選擇的參數,並且不處理參數(肥皂體是空的) – 2011-05-11 13:14:13

1

一個已知的bug,我定會這樣:

class MyPlugin(DocumentPlugin): 
    def setChoice(self, context): 
     if not context.children: 
      return 
     for i in context.children: 
      if i.name == "choice": 
       for j in i.children: 
        i.parent.append(j) 
      else: 
       self.setChoice(i) 

    def parsed(self, context): 
     self.setChoice(context.document) 


plugin = MyPlugin() 
client = Client("http://127.0.0.1/service?wsdl", plugins=[plugin])