Created
January 13, 2013 14:01
-
-
Save bancek/4524241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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