2011-05-11 218 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])