4

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?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
Andrey Koltsov
  • 1,956
  • 6
  • 24
  • 43

3 Answers3

5

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

Andrey Koltsov
  • 1,956
  • 6
  • 24
  • 43
1

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])
Kedr
  • 11
  • 1
0

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

tomaski
  • 957
  • 8
  • 15