In this section, we'll quickly show you how to write a client to test out your newborn stateful Web Service. The client will have minimal error-checking, but should work fine just connecting on your local host. One important thing to check before you start is the firewall setup on your computer and make sure that the firewall allows connections to/from your localhost (127.0.0.1). You do not need to open any holes in your external connectivity firewall for this client to work.
Add the three footnoted lines below to client.py or just cut and paste the entire example.
############################################################################ # Automatically generated by wsdl2web.py # See LBNLCopyright for copyright notice! ########################################################################### from twisted.python import log from twisted.internet import reactor import ZSI from pyGridWare.utility.scripts.client import GetBasicOptParser, GetPortKWArgs, SetUp from generated.SimpleMath.stubs import SimpleMath as CLIENT def main(**kw): locator = CLIENT.MathServiceLocator() port = locator.getMathPortType(**kw) port.add(CLIENT.AddInputMessage(10))port.subtract(CLIENT.SubtractInputMessage(3))
print "VALUE: ", port.getValueRP(CLIENT.GetValueRPInputMessage())
# Factory METHOD Just guessing here #response = port.create(CLIENT.CreateRequest()) #kw['endPointReference'] = response._EndpointReference #iport = locator.getMathPortType(**kw) reactor.stop() if __name__ == '__main__': op = GetBasicOptParser() (options, args) = op.parse_args() SetUp(options) kw = GetPortKWArgs(options) reactor.callWhenRunning(main, **kw) reactor.run()
You should see the following output. If you want to see the soap messages send debugging information to stdout by using -d 1