programming
python
webdev
flask
Python SOAP server (flask) + wsdl generation
Simple tutorial how quickly create SOAP server using python "Flask-Enterprise" package for "flash" web framework.
Example comes with basic client using "suds" package.
Install
$ pip install Flask-Enterprise
Create app file
soap.py from time import ctime
from flask import Flask
from flaskext.enterprise import Enterprise
app = Flask ( __name__ )
enterprise = Enterprise ( app )
class DemoService ( enterprise . SOAPService ):
__soap_server_address__ = '/soap'
__soap_target_namespace__ = 'ns'
@enterprise . soap ( _returns = enterprise . _sp . String )
def get_time ( self ):
return ctime ()
if __name__ == '__main__' :
app . run ( host = '127.0.0.1' , port = 5555 )
Run service
Create client
client.py from suds.client import Client
c = Client ( 'http://127.0.0.1:5555/soap?wsdl' )
print c . service . get_time ()
Run test
$ python client.py
Tue Aug 13 19 :49:53 2013