SHARE
TWEET

Untitled

a guest Sep 26th, 2011 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import logging
  2.  
  3. from rpclib.application import Application
  4. from rpclib.decorator import rpc
  5. from rpclib.interface.wsdl import Wsdl11
  6. from rpclib.protocol.soap import Soap11
  7. from rpclib.service import ServiceBase
  8. from rpclib.model.primitive import Integer
  9. from rpclib.model.primitive import String
  10. from rpclib.model.complex import ComplexModel
  11. from rpclib.server.wsgi import WsgiApplication
  12.  
  13. class data_response(ComplexModel):
  14.         first = String
  15.         second = Integer
  16.  
  17. class testf_response(ComplexModel):
  18.         state = String
  19.         data = data_response
  20.  
  21. class testt(ServiceBase):
  22.  
  23.         @rpc(String, String, _returns=testf_response)
  24.         def testf(self, first, second):
  25.                 result = testf_response()
  26.                 result.state = "ff"
  27.                 result.data = data_response()
  28.                 result.data.first = "test"
  29.                 result.data.second = 2
  30.                 return result
  31.  
  32. if __name__=='__main__':
  33.         try:
  34.                 from wsgiref.simple_server import make_server
  35.         except ImportError:
  36.                 print "Error: example server code requires Python >= 2.5"
  37.  
  38.         logging.basicConfig(level=logging.DEBUG)
  39.         logging.getLogger('rpclib.protocol.xml').setLevel(logging.DEBUG)
  40.  
  41.         application = Application([testt], 'testt', interface=Wsdl11(), in_protocol=Soap11(), out_protocol=Soap11())
  42.  
  43.         server = make_server('127.0.0.1', 8080, WsgiApplication(application))
  44.  
  45.         print "listening to http://127.0.0.1:8080"
  46.         print "wsdl is at: http://localhost:8080/?wsdl"
  47.  
  48.         server.serve_forever()
  49.  
  50.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top