3

Now i use twisted.soap to build my soap server, I'd like to build a function with plural 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 test :

    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 gives me back like this:

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

it looks like the args order are totally wrong so what happens and how can i ensure the right order ?

Daemoneye
  • 107
  • 2
  • 10
  • But if i call the method like this way it works fine:p.searchFlight('3548',"北京飞机场","上海飞机场") – Daemoneye Mar 28 '12 at 07:53

1 Answers1

1

Without seeing functions.searchFlight, it's a little hard to tell, but it appears that you're passing a dict to in in a callback, then assuming that the items in the dict are in a particular order (they're not).

Change the signature of functions.searchFlight to take a tuple, and call it with a tuple in the order you want. (or pass in an ordered dict...or don't assume the dict's items are in the order that you created it in).

Gerrat
  • 28,863
  • 9
  • 73
  • 101