473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

XML-RPC

Ben
Hi all,

I think this is a very simple problem.. I'm trying to run an xml-rpc
server given in SimpleXMLRPCServer.py file that comes with Python and
wrote a very simple client to interact with it but it's giving me
errors.

The server code is as follows:

#!/usr/local/bin/python2.2

from SimpleXMLRPCServer import *

# Install an instance with custom dispatch method:

class Math:
def _dispatch(self, method, params):
if method == 'pow':
return apply(pow, params)
elif method == 'add':
return params[0] + params[1]
else:
raise 'bad method'
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(Math())
server.serve_forever()

Client code:
#!/usr/local/bin/python2.2

import xmlrpclib
myserver = xmlrpclib.Server("http://localhost:8000")

p= [2,2]
print myserver._dispatch("add",p)

The error I get:
.......
.......
xmlrpclib.Fault: <Fault 1: 'bad method:None'>

What have I done wrong?

Thanks
Ben
Jul 18 '05 #1
1 2605
Ben wrote:
...
def _dispatch(self, method, params):
if method == 'pow':
return apply(pow, params)
elif method == 'add':
return params[0] + params[1]
else:
raise 'bad method' ... p= [2,2]
print myserver._dispatch("add",p)


the way you've coded your server, the client should call myserver.add(2,2)
and NOT what you've coded on the client side.

To see why add a simple print of method and params as the first line
of _dispatch and you'll see:

for the call to .add(2,2):
dispatching 'add' (2, 2)

for the call to ._dispatch('add', [2,2]):
dispatching '_dispatch' ('add', [2, 2])

i.e. the way you call it string '_dispatch' becomes the method and the tuple
of args that ends in params isn't what you apparently think it should be.
Alex

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil Powell | last post by:
// PROCESS XML CONTENT INTO DYNAMICALLY-NAMED ARRAYS foreach (array('mime', 'state', 'country') as $val) { $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);...
0
by: Stylus Studio | last post by:
World's Most Advanced XML Schema Editor Adds Support for IBM AlphaWorks XML Schema Quality Checker to Improve XML Schema Style and Quality BEDFORD, MA -- 09/13/2005 -- Stylus Studio...
5
by: Kurt Bauer | last post by:
I have an ASP group calendar application which pulls calendar data from Exchange via webdav into an XML string. I then loop the XML nodes to populate a collection of appointments. Finally I use...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
0
by: UncleRic | last post by:
Environment: Mac OS X (10.4.10) on MacBook Pro I'm a Perl Neophyte. I've downloaded the XML::Parser module and am attempting to install it in my working directory (referenced via PERL5LIB env): ...
9
by: Lie | last post by:
Why this generates AttributeError, then not? Python 2.5.2 (r252:60911, Apr 21 2008, 11:17:30) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most...
10
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I had a program and it always works fine and suddenly it gives me the following message when a pass a xml file to our server program: error code: -1072896680 reason: XML document must...
0
by: Jacker | last post by:
Xpress Author for MS Word XML Documents In.vision Research empowers knowledge workers to create complex XML documents in Microsoft Word (2000-2003) with a normal Word experience. Deploy XML...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.