肥皂水和选择标签

时间:2011-05-11 11:24:10

标签: python wsdl suds choice

如何使用“choice”参数生成对方法的请求?

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?

3 个答案:

答案 0 :(得分:5)

这是肥皂水中的一个已知错误 https://fedorahosted.org/suds/ticket/342

答案 1 :(得分:1)

我修好了:

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

答案 2 :(得分:0)

如果没有看到整个wsdl,很难知道,你的链接是你的本地机器。

Suds Client类使用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")

相关问题