suds and choice tag
Asked Answered
R

3

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?

Ralfston answered 11/5, 2011 at 11:24 Comment(0)
R
5

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

Ralfston answered 12/5, 2011 at 11:49 Comment(0)
P
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])
Pulse answered 28/12, 2015 at 14:6 Comment(0)
F
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")

Frontogenesis answered 11/5, 2011 at 12:49 Comment(4)
doesn't work <ns1:Body> <ns0:GetMethodRequest/> </ns1:Body> soap body is emptyRalfston
Again, not sure without seeing the wsdl. The method I described is how suds calls methods on a web service.Frontogenesis
I know how to call suds methods, I don't why suds doesn't show arguments for choices, and doesn't process args (soap body is empty)Ralfston
Andrew, did you ever find a solution?Sciatica

© 2022 - 2024 — McMap. All rights reserved.