Weird problem with XMLRPC -> ('405', 'Method Not Allowed')
I've run into a problem with my twisted xmlrpc test server (using twisted version 2.01 or 2.1). Every time the client calls the echo function a '405 Method Not Allowed is returned'. This code ran in Twisted 1.3 without problems ... what's changed besides the zope interface implements. Any ideas? Here's the server code: #!/usr/bin/env python # -*- coding: iso-8859-15 -*- """""" import sys from twisted.application import internet, service from twisted.internet import reactor, protocol, defer from twisted.web import resource, server, static, xmlrpc from twisted.python import components, rebuild from zope.interface import Interface, implements class myXMLRPC(xmlrpc.XMLRPC): """This class contains all root xmlrpc methods and the modules subhandler.""" def __init__(self, service): xmlrpc.XMLRPC.__init__(self) self.service = service def xmlrpc_echo(self, x): """Simple echo function""" return x def catchError(err): return "Internal error in server" class IowwService(components.Interface): """""" def rebuild(self, modname): """Rebuild classes in given module""" class httpResource(resource.Resource): implements(resource.IResource) def __init__(self, service): resource.Resource.__init__(self) self.service = service self.putChild('RPC2', myXMLRPC(self.service)) def render(self, request): self._clientIP = request.getClientIP() return resource.Resource.render(self, request) def render_GET(self, request): """Process HTTP GET Requests.""" return '<html><body><h3>Not Implemented</h3></body></html>' def getChild(self, path, request): """This method handles http calls""" return httpResource(self.service) components.registerAdapter(httpResource, IowwService, resource.IResource) class owwService(service.Service): """""" implements(IowwService) def rebuild(self, modname): """Rebuild classes in given module""" mod = sys.modules[modname] rebuild.rebuild(mod) def main(): """""" application = service.Application('OWW', uid=100, gid=100) s = owwService() serviceCollection = service.IServiceCollection(application) internet.TCPServer(7080, server.Site(resource.IResource(s))).setServiceParent(serviceCollection) serviceCollection.startService() reactor.run() if __name__ == '__main__': main() And the client code: #!/usr/bin/env python from twisted.web.xmlrpc import Proxy from twisted.internet import reactor def printValue(value): print repr(value) reactor.stop() def printError(error): print 'error', error reactor.stop() proxy = Proxy('http://localhost:7080') proxy.callRemote('echo', 'hello world').addCallbacks(printValue, printError) reactor.run()
Remi Cool wrote:
I've run into a problem with my twisted xmlrpc test server (using twisted version 2.01 or 2.1).
Every time the client calls the echo function a '405 Method Not Allowed is returned'.
This code ran in Twisted 1.3 without problems ... what's changed besides the zope interface implements.
A print statement in the render method:
def render(self, request):
self._clientIP = request.getClientIP()
print 'REQUEST:', request
return resource.Resource.render(self, request)
gave: "
participants (1)
-
Remi Cool