<s> import tornado . httpserver <EOL> import tornado . ioloop <EOL> from tornadows import soaphandler <EOL> from tornadows import webservices <EOL> from tornadows import xmltypes <EOL> from tornadows . soaphandler import webservice <EOL> class EchoService ( soaphandler . SoapHandler ) : <EOL> """<STR_LIT>""" <EOL> @ webservice ( _params = xmltypes . String , _returns = xmltypes . String ) <EOL> def echo ( self , message ) : <EOL> return '<STR_LIT>' % message <EOL> class EchoTargetnsService ( soaphandler . SoapHandler ) : <EOL> """<STR_LIT>""" <EOL> targetns_address = '<STR_LIT>' <EOL> @ webservice ( _params = xmltypes . String , _returns = xmltypes . String ) <EOL> def echo ( self , message ) : <EOL> return '<STR_LIT>' % message <EOL> class CountService ( soaphandler . SoapHandler ) : <EOL> """<STR_LIT>""" <EOL> @ webservice ( _params = xmltypes . Array ( xmltypes . String ) , _returns = xmltypes . Integer ) <EOL> def count ( self , list_of_values ) : <EOL> length = len ( list_of_values ) <EOL> return length <EOL> class DivService ( soaphandler . SoapHandler ) : <EOL> """<STR_LIT>""" <EOL> @ webservice ( _params = [ xmltypes . Float , xmltypes . Float ] , _returns = xmltypes . Float ) <EOL> def div ( self , a , b ) : <EOL> result = a / b <EOL> return result <EOL> class FibonacciService ( soaphandler . SoapHandler ) : <EOL> """<STR_LIT>""" <EOL> @ webservice ( _params = xmltypes . Integer , _returns = xmltypes . Array ( xmltypes . Integer ) ) <EOL> def fib ( self , n ) : <EOL> a , b = <NUM_LIT:0> , <NUM_LIT:1> <EOL> result = [ ] <EOL> while b < n : <EOL> result . append ( b ) <EOL> a , b = b , a + b <EOL> return result <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> service = [ ( '<STR_LIT>' , EchoService ) , <EOL> ( '<STR_LIT>' , EchoTargetnsService ) , <EOL> ( '<STR_LIT>' , CountService ) , <EOL> ( '<STR_LIT>' , DivService ) , <EOL> ( '<STR_LIT>' , FibonacciService ) ] <EOL> app = webservices . WebService ( service ) <EOL> ws = tornado . httpserver . HTTPServer ( app ) <EOL> ws . listen ( <NUM_LIT> ) <EOL> tornado . ioloop . IOLoop . instance ( ) . start ( ) </s>
