By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,538 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,538 IT Pros & Developers. It's quick & easy.

XML-RPC server-client communication

P: n/a
Hi all,

I try to implement a python xml-rpc server and call it from a php
client. If the server and the client are on the same machine
(localhost) the communication between them is just fine. When I start
the server on a different host I don't get an answer.
What is missing there?? I tried also to set username and password,
cause I thought there is an authenticate issue but it didn't work
either.
Here is my code:

python server:
<code>
import SimpleXMLRPCServer
from re import *
import string

#The server object
class myFunctions:
def myTest(self, code):
mya = findall('#include.+',code)
stringo = string.join(mya,', ')
return stringo

calendar_object = myFunctions()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("xxx.xxx.xx x.xxx",
22999))
server.register_instance(calendar_object)

#Go into the main listener loop
print "Listening on port 22999"
server.serve_forever()
</code>

php client:
<code>
<?
require_once("XML/RPC.php");

$code = '#include<iostream>
#include<cmath>';

$function = "myTest";

$param = new XML_RPC_Value(htmlspecialchars($code), "string");
$params = array($param);
$message = new XML_RPC_Message($function, $params);
$client = new XML_RPC_Client("/new2.py","xxx.xxx.xxx.xxx",22999);

print_r($client);
$result = $client->send($message);
print_r($result);

$value = $result->value();
$number = $value->scalarval();
echo "<p><b>Return Value:</b$number </p>";

echo "<p>Headers are: $number </p>";
?>
</code>

Thanx in advance :)

Jul 5 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Stefka írta:
Hi all,

I try to implement a python xml-rpc server and call it from a php
client. If the server and the client are on the same machine
(localhost) the communication between them is just fine. When I start
the server on a different host I don't get an answer.
Please go to the machine where you php program resides, and check if the
server is not blocked by firewall rules. For example, do

telnet xxx.xxx.xxx.xxx 22999

If it does not connect, then the problem is with your network or
firewall settings. (I thought this is the most probable...)

Best,

Laszlo
What is missing there?? I tried also to set username and password,
cause I thought there is an authenticate issue but it didn't work
either.
Jul 5 '06 #2

P: n/a
Hi,

thanx for the hint :)! I ran a port scan and it turned out, that the
port was realy closed.
Thanx again!

greetz,
Stefka

Laszlo Nagy wrote:
Please go to the machine where you php program resides, and check if the
server is not blocked by firewall rules. For example, do

telnet xxx.xxx.xxx.xxx 22999

If it does not connect, then the problem is with your network or
firewall settings. (I thought this is the most probable...)

Best,

Laszlo
Jul 5 '06 #3

P: n/a
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("xxx.xxx.xx x.xxx",
22999))
Could it be that xxx.xxx.xxx.xxx stands for '127.0.0.1'? If so... rename
it to 'localhost'. If you bind a port to 127.0.0.1 it will be found only
on the same machine.
Greetings,
Marco

Jul 6 '06 #4

P: n/a
no, its an extern IP adress. For my needs the server and the client
must be on different machines. But I opened the port and it worked.
Thanks anyway :)

Greetz,
Stefka

Marco Aschwanden wrote:
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("xxx.xxx.xx x.xxx",
22999))

Could it be that xxx.xxx.xxx.xxx stands for '127.0.0.1'? If so... rename
it to 'localhost'. If you bind a port to 127.0.0.1 it will be found only
on the same machine.
Greetings,
Marco
Jul 6 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.