1
from suds.client import Client

from suds.transport.https import HttpAuthenticated

import urllib2

class methodinvokeclass():

    def methodinvokemethod(self,*args):

        method=args[1]         

        c=args[2]

        #method=LatLonListZipCode in the variable above
        response=c.service.method("90210")--How should I make this work ?

        #response=c.service.LatLonListZipCode("90210")
        #The above snippet works, but this not what I want
        #As I want to make it generic "method" and ask user in the run time to select     ---       #methodname
4

1 回答 1

0
#method constains a string (eg: 'LatLonListZipCode')
method_to_call = getattr(c.service, method)
response = method_to_call("90210")

此外,如果找不到该方法,您必须进行一些错误检查。

于 2011-04-07T12:19:08.743 回答