Re: XML RPC Problem....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fredrik Lundh

    Re: XML RPC Problem....

    Usman Ajmal wrote:
    And i also fount that a typical system.auth call will look like:
    >
    POST /xmlrpc/clarens_server. py HTTP/1.0
    Host: localhost
    User-Agent: xmlrpclib.py/0.9.9 (by www.pythonware.com <http://www.pythonware. com>)
    >
    Content-Type: text/xml
    Content-Length: 105
    AUTHORIZATION: Basic MkhVTm9VazYxbXA rVEZLS0dCY2tIRl A3bjVzPQo6RnJvb SBi
    <?xml version='1.0'?>
    <methodCall>
    <methodName>sys tem.auth</methodName>
    >
    <params>
    </params>
    </methodCall>
    >
    >
    Problem is that i don't know how do i generate above xml system.auth
    call. Can anyone please tell me how do call a function, setting the
    header of the call too?
    you need to plugin a custom transport. see this page for an example:



    in your case, it should be sufficient to override send_request, e.g.
    (untested):

    class SecureTransport (xmlrpclib.Tran sport):

    def set_authorizati on(self, ustring, text_ucert):
    self.authoriati on = encodestring(
    "%s:%s" % (ustring,text_u cert)
    )

    def send_request(se lf, connection, handler, request_body):
    connection.putr equest("POST", handler)
    connection.puth eader("Authoriz ation",
    "Basic %s" % self.authorizat ion
    )

    and instantiate the transport by doing

    t = SecureTransport ()
    t.set_authoriza tion(ustring, text_ucert)

    before passing to the server proxy.

    </F>

Working...