Soap gets arguments with wrong order in twisted

Now I am using twisted.soap to create my soap server, I would like to build a function with multiple arguments like this:

def soap_searchFlight(self,name=None,startpoint=None,destination=None):
    d=Deferred()
    d.addCallback(functions.searchFlight)
    d.addErrback(functions.failure)
    print "name"+name
    print "startpoint"+startpoint
    print "destination"+destination
    requestdic={"name":name,"startpoint":startpoint,"destination":destination}
    print requestdic
    d.callback(requestdic)
    return d.result

      

and I wrote a script to check:

    import SOAPpy
    import twisted
    p = SOAPpy.SOAPProxy('http://localhost:7080/')
    p.config.dumpSOAPOut=1
    p.config.dumpSOAPIn=1
    print p.searchFlight(name='3548',startpoint="北京飞机场",destination="上海飞机场")

      

It brings me back like this:

name上海飞机场
startpoint北京飞机场
destination3548

      

it looks like the order of the args is completely wrong, and what is going on and how can I ensure the order is correct?

+3


source to share


1 answer


Without seeing functions.searchFlight

, it's a bit tricky to tell, but it seems that you are passing the request in a callback and then assuming that the elements in the dict are in a specific order (they are not).



Change the signature functions.searchFlight

to take a tuple and call it with the tuple in the order you want. (or pass in an ordered dict ... or don't assume the elements of the dict are in the order you created it).

+1


source







All Articles