problem with JSON-RPC

M

Michel Perez

Hi everybody:
I'm trying to use JSON-RPC to provide my services but produce this
exception:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "jsonrpc/proxy.py", line 43, in __call__
resp = loads(respdata)
File "jsonrpc/json.py", line 211, in loads
raise JSONDecodeException('Expected []{}," or Number, Null, False or
True')
jsonrpc.json.JSONDecodeException: Expected []{}," or Number, Null, False
or True


This is what am doing


==== configuration file for apache ====
<code lang="apache.conf">
Alias /services/ //home/mperez/Desktop/test_jsonrpc/

<Location /services/>
Options Indexes MultiViews FollowSymLinks
Order deny,allow
Allow from All

AddHandler mod_python .py
PythonHandler jsonrpc
</Location>
</code>

==== service for jsonrpc test.py ====
<code lang="python">
from jsonrpc import ServiceMethod

class MyService(object):
@ServiceMethod
def echo(self, msg):
return msg

service = MyService()
</code>

==== service client ====
<code lang="python">
#!/usr/bin/env python
from jsonrpc import ServiceProxy
s = ServiceProxy("http://localhost/services/test.py")
print s.echo("foobar")
</code>

Regards
 
D

Diez B. Roggisch

Michel said:
Hi everybody:
I'm trying to use JSON-RPC to provide my services but produce this
exception:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "jsonrpc/proxy.py", line 43, in __call__
resp = loads(respdata)
File "jsonrpc/json.py", line 211, in loads
raise JSONDecodeException('Expected []{}," or Number, Null, False or
True')
jsonrpc.json.JSONDecodeException: Expected []{}," or Number, Null, False
or True


This is what am doing


==== configuration file for apache ====
<code lang="apache.conf">
Alias /services/ //home/mperez/Desktop/test_jsonrpc/

<Location /services/>
Options Indexes MultiViews FollowSymLinks
Order deny,allow
Allow from All

AddHandler mod_python .py
PythonHandler jsonrpc
</Location>
</code>

==== service for jsonrpc test.py ====
<code lang="python">
from jsonrpc import ServiceMethod

class MyService(object):
@ServiceMethod
def echo(self, msg):
return msg

service = MyService()
</code>

==== service client ====
<code lang="python">
#!/usr/bin/env python
from jsonrpc import ServiceProxy
s = ServiceProxy("http://localhost/services/test.py")
print s.echo("foobar")

Try s.echo("'foobar'")

JSON needs quotes around string-literals.

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top