SHARE
TWEET

Untitled

a guest Jun 17th, 2014 204 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import logging
  2. from spyne.application import Application
  3. from spyne.decorator import rpc
  4. from spyne.protocol.json import JsonDocument
  5. from spyne.protocol.http import HttpRpc
  6. from spyne.service import ServiceBase
  7. from spyne.model.primitive import Integer, String, Unicode
  8. from spyne.model.enum import Enum
  9. from spyne.model.complex import ComplexModel
  10. from spyne.server.wsgi import WsgiApplication
  11.  
  12.  
  13.  
  14. RequestStatus = Unicode(values=['new', 'processed'])
  15. #RequestStatus = String(values=('new', 'processed'))
  16. #RequestStatus = Unicode(values=(u'new', u'processed'))
  17.  
  18.  
  19.  
  20. class DemoService(ServiceBase):
  21.         @rpc(RequestStatus, _returns=Integer)
  22.         def DemoFunction(ctx, data):
  23.                 #import pdb
  24.                 #pdb.set_trace()
  25.                 print data
  26.                 return 4
  27.  
  28.  
  29.  
  30. if __name__ == '__main__':
  31.         from wsgiref.simple_server import make_server
  32.         logging.basicConfig(level=logging.DEBUG)
  33.  
  34.         application = Application([DemoService], 'SpyneDemo.http',
  35.                                 in_protocol=JsonDocument(validator='soft'),
  36.                                 out_protocol=JsonDocument(ignore_wrappers=True),
  37.                 )
  38.  
  39.         wsgi_application = WsgiApplication(application)
  40.  
  41.         server = make_server('', 8000, wsgi_application) #any interface
  42.  
  43.         logging.info("listening at all interfaces on port 8000")
  44.         logging.info("wsdl is at: http://ANY:8000/?wsdl")
  45.  
  46.         server.serve_forever()
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