Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/01/2011, 09:11
MikSCaT
 
Fecha de Ingreso: diciembre-2010
Mensajes: 3
Antigüedad: 13 años, 4 meses
Puntos: 0
XML-RPC entre JavaScript y Phyton

Hola.
No se muy bien si este post está bien ubicado aquí, pero me ha parecido el mas adecuado.
Mi problema es el siguiente. Estoy implementado un servicio web utilizando el protocolo XML-RPC.
El servidor está escrito en Phyton y es el siguiente:

Código:
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler

# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
    rpc_paths = ('/RPC2',)

# Create server
server = SimpleXMLRPCServer(("http://www.miks.es", 8000),requestHandler=RequestHandler)
server.register_introspection_functions()

# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register_function(pow)

# Register a function under a different name
def adder_function(x,y):
    return x + y
server.register_function(adder_function, 'add')

# Register an instance; all the methods of the instance are
# published as XML-RPC methods (in this case, just 'div').
class MyFuncs:
    def div(self, x, y):
        return x // y

server.register_instance(MyFuncs())

# Run the server's main loop
server.serve_forever()
El cliente está implementado en JavaScript y para comunicarme con el servidor utilizo la siguiente librería.
http://www.zentus.com/js/xmlrpc.js.html

La cuestión es que hago la llamada al servidor tal y como indica en el anterior enlace pero no hay manera de establecer la comunicación.

La llamada la realizo de la siguiente manera:

Código:
xmlrpc("http://www.miks.es/:8000", "add", [2,3], 
                                     function(ret) {alert("loaded,got " + ret);}, 
                                     function(err) {alert("error occurred: " + err);}, 
                                     function() {alert("finished");});
Esta llamada invoca a la función add del servidor con los parámetros 2 y 3 per solo recibo un mensaje de "Connection error".

Espero que puedan ayudarme.
Muchas gracias de antemano.