I downloaded the latest web2py 1.99.2 followed web2py book on JSONRPC http://www.web2py.com/book/default/chapter/09#XMLRPC
I am able to test jsonrpc service as below: from gluon.contrib.simplejsonrpc import ServerProxy URL = "http://127.0.0.1:8100/myapp/default/call/jsonrpc" service = ServerProxy(URL, verbose=True) print service.add(1, 2) connect: (127.0.0.1, 8100) send: 'POST /myapp/default/call/jsonrpc HTTP/1.0\r\nHost: 127.0.0.1:8100\r\nUser -Agent: xmlrpclib.py/1.0.1 (by www.pythonware.com)\r\nContent-Type: application/ json\r\nContent-Length: 53\r\n\r\n' send: '{"params": [1, 2], "id": 2121494614, "method": "add"}' reply: 'HTTP/1.1 200 OK\r\n' header: Expires: Mon, 31 Oct 2011 16:43:02 GMT header: Content-Type: application/json; charset=utf-8 header: X-Powered-By: web2py header: Pragma: no-cache header: Cache-Control: no-store, no-cache, must-revalidate, post- check=0, pre-ch eck=0 header: Date: Mon, 31 Oct 2011 16:43:02 GMT header: Server: Rocket 1.2.4 Python/2.5.4 header: Content-Length: 64 header: Connection: close body: '{"error": null, "version": "1.1", "id": 2121494614, "result": 3}' 3 In a nutshell: web2py is simply cool ! Wen On Oct 31, 12:05 am, Jonathan Lundell <jlund...@pobox.com> wrote: > On Oct 30, 2011, at 9:00 PM, wwwgong wrote: > > > ok, do you know a javascript client example? Thanks, > > Not offhand, no. But there's JSON-RPC documentation on the web that explains > the protocol pretty well. And there's a client in the web2py contrib > directory. > > > > > > > > > > > On Oct 30, 12:42 am, Jonathan Lundell <jlund...@pobox.com> wrote: > >> On Oct 29, 2011, at 9:36 PM, wwwgong wrote: > > >>> Hi, > >>> add 2 functinos in myapp/controller/default.py > > >>> @service.run > >>> def concat(a,b): > >>> return a+b > > >>> @service.jsonrpc > >>> def concat2(a,b): > >>> return a+b > > >>> test them using browser > >>> 1) > >>>http://127.0.0.1:8000/myapp/default/call/run/concat?a=hello&b=world > >>> --> return 'helloworld' > > >>> 2) > >>>http://127.0.0.1:8000/myapp/default/call/jsonrpc/concat2?a=hello&b=world > >>> --> error > >>> Traceback (most recent call last): > >>> File "gluon/restricted.py", line 192, in restricted > >>> File "C:/web2py/applications/myapp/controllers/default.py", line > >>> 100, in <module> > >>> File "gluon/globals.py", line 145, in <lambda> > >>> File "C:/web2py/applications/myapp/controllers/default.py", line 80, > >>> in call > >>> File "gluon/tools.py", line 3937, in __call__ > >>> File "gluon/tools.py", line 3776, in serve_jsonrpc > >>> File "gluon/contrib/simplejson/__init__.py", line 386, in loads > >>> File "gluon/contrib/simplejson/decoder.py", line 403, in decode > >>> File "gluon/contrib/simplejson/decoder.py", line 421, in raw_decode > >>> JSONDecodeError: No JSON object could be decoded: line 1 column 0 > >>> (char 0) > > >>> I am able to run todoApp from web2py book, so json module should be > >>> working, but why cannot I test jsonrpc this way in browser? > > >> The JSON-RPC service expects a JSON object (with specific content) as > >> input. You're not providing it. > > >>> Thanks, > >>> Wen