suds and choice tag

吃可爱长大的小学妹 提交于 2019-12-22 07:57:23

问题


how to generate request to method with "choice" arguments?

part of wsdl at http://127.0.0.1/service?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>

when I do

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

I see

GetMethod()

without any arguments.

how I can call GetMethod with byA or with byB?


回答1:


It's a known bug in suds https://fedorahosted.org/suds/ticket/342




回答2:


I fixed it so:

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



回答3:


It's hard to know without seeing the whole wsdl, your link is to your local machine.

The Suds Client class uses the Service Class as an instance variable for interacting with wsdl. Have you tried something like this?

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

or

client.service.GetMethod("byB")



来源:https://stackoverflow.com/questions/5963404/suds-and-choice-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!