Skip to content

Instantly share code, notes, and snippets.

@rochacbruno
Created July 15, 2011 00:32
Show Gist options
  • Save rochacbruno/1083807 to your computer and use it in GitHub Desktop.
Save rochacbruno/1083807 to your computer and use it in GitHub Desktop.
Webservices with web2py
#soap
from gluon.contrib.pysimplesoap.client import SoapClient
client = SoapClient(wsdl="http://localhost:8000/app/default/call/soap?WSDL")
print client.MyFunction(a=1,b=2)
#{'result': 3}
#xmlrpc
from xmlrpclib import ServerProxy
server = ServerProxy(
'http://127.0.0.1:8000/app/default/call/xmlrpc')
print server.books()
@service.json
def concat(a,b):
return a+b
@service.xmlrpc
def sum(x,y):
return str(x + y) + "- Hello!"
@service.xmlrpc
def books(c=None):
if c:
query = db(db.books.categoria==c).select()
else:
query = db().select(db.books.ALL)
return query.as_list()
@service.soap('MyFunction', returns={'result':int}, args={'a':int, 'b':int,})
def add(a,b):
return a+b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment