Thank for your help<br><br>It's right, the code number 1 is not well structured that is the reason I modified it for the code number 2<br>But in the first one the xml_rpc call retun the good answer and in the second one I received a error message<br>
<br>I tried your code,this is a better structure (The Class Resource is in the next example in the book)<br><br> But the code doesn't work, I have the same error message about xml_rpc answer<br><br>[Failure instance: Traceback: <class 'xmlrpclib.Fault'>: <Fault -32602: 'server error. invalid method parameters'><br>
C:\python27\lib\site-packages\twisted\internet\posixbase.py:263:_disconnectSelectable<br>C:\python27\lib\site-packages\twisted\internet\tcp.py:433:connectionLost<br>C:\python27\lib\site-packages\twisted\internet\tcp.py:277:connectionLost<br>
C:\python27\lib\site-packages\twisted\web\xmlrpc.py:373:connectionLost<br>--- <exception caught here> ---<br>C:\python27\lib\site-packages\twisted\web\xmlrpc.py:444:parseResponse<br>C:\python27\lib\xmlrpclib.py:1137:loads<br>
C:\python27\lib\xmlrpclib.py:793:close<br>]<br><br>The issue is how to call xml_rpc callRemote correctly ?<br><br>Thank again<br><br><div class="gmail_quote">Le 17 avril 2012 04:46, Phil Mayers <span dir="ltr"><<a href="mailto:p.mayers@imperial.ac.uk">p.mayers@imperial.ac.uk</a>></span> a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 04/17/2012 03:38 AM, joel tremblet wrote:<br>
<br>
> I try to declare the Proxy(OF_XMLRPC_URL) differently, without success<br>
><br>
> Where is my mistake ....<br>
<br>
</div>That code is all wrong, and (to be blunt) pretty horrible too.<br>
<br>
Why have you re-implemented a HTTP protocol yourself? You're bound to<br>
get this wrong (and in fact have, in several ways). Don't do this. Use<br>
the HTTP stack that comes with Twisted.<br>
<br>
Anyway, your major mistake in the 1st example is that, at the end of the<br>
lineReceived method, you always call the sendResponse() method. This<br>
happens immediately, before the XMLRPC reply has come back, so your code<br>
sends "no value". You need to attach the sendResponse method to the<br>
deferred returned from the xmlrpc call.<br>
<br>
I would junk it and start again, like this:<br>
<br>
from twisted.web import server, resource, xmlrpc, http<br>
<br>
proxy = xmlrpc.Proxy(XMLRPC_URL)<br>
<br>
class MyResource(resource.Resource):<br>
isLeaf = True<br>
def render_GET(self, request):<br>
sessid = request.args['sessid'][0]<br>
keyid = request.args['keyid'][0]<br>
d = proxy.callRemote('checkCommand', sessid, keyid)<br>
d.addCallback(self._done, request)<br>
d.addErrback(self._err, request)<br>
return server.NOT_DONE_YET<br>
<br>
def _done(self, res, request):<br>
if res!=1:<br>
request.setResponseCode(406)<br>
else:<br>
request.setResponseCode(200)<br>
request.finish()<br>
<br>
def _err(self, failure, request):<br>
request.setResponseCode(405)<br>
request.finish()<br>
<br>
reactor.listenTCP(8080, server.Site(MyResource()))<br>
reactor.run()<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br>