Skip to content

Instantly share code, notes, and snippets.

@bancek
Created January 13, 2013 14:01
Show Gist options
  • Save bancek/4524241 to your computer and use it in GitHub Desktop.
Save bancek/4524241 to your computer and use it in GitHub Desktop.
# pip install pysimplesoap
import os
import random
from BaseHTTPServer import HTTPServer
from pysimplesoap.server import SoapDispatcher, SOAPHandler
def GetQuantityInStock(ProductName):
return random.randint(0, 500)
dispatcher = SoapDispatcher(
'IProductDetails',
location = 'http://tempuri.org/',
action = 'http://tempuri.org/IProductDetails',
namespace = 'http://tempuri.org/IProductDetails/svc.wsdl', prefix='ns0',
trace = True,
ns = True)
dispatcher.register_function('GetQuantityInStock', GetQuantityInStock,
returns={'GetQuantityInStockResult': int},
args={'ProductName': str})
if __name__ == '__main__':
port = int(os.environ.get('PORT', 8080))
print 'Starting server on port 8080...'
httpd = HTTPServer(('', port), SOAPHandler)
httpd.dispatcher = dispatcher
httpd.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment