xmlrpc username/password failures

penglish1 at gmail.com penglish1 at gmail.com
Fri Feb 11 20:31:29 EST 2005


Hi,

 I'm trying to get xmlrpc working with usernames and passwords and
 having some issues. This is on Linux (WBEL3.0R1).

First of all with python 2.2.3 which comes with WBEL the following
simple code fails (passwords & server names altered to protect the
innocent):

#!/usr/bin/python

import xmlrpclib
from xmlrpclib import *

test =
Server('http://3tier:My&Passw6@www.server.net/Forecast')

print test.ReturnSimpleInt()

Returns the following error:

Traceback (most recent call last):
  File "./testCondon.py", line 8, in ?
    print test.ReturnSimpleInt()
  File "/usr/lib/python2.2/xmlrpclib.py", line 821, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.2/xmlrpclib.py", line 975, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.2/xmlrpclib.py", line 833, in request
    h = self.make_connection(host)
  File "/usr/lib/python2.2/xmlrpclib.py", line 862, in make_connection
    return httplib.HTTP(host)
  File "/usr/lib/python2.2/httplib.py", line 969, in __init__
    self._setup(self._connection_class(host, port, strict))
  File "/usr/lib/python2.2/httplib.py", line 491, in __init__
    self._set_hostport(host, port)
  File "/usr/lib/python2.2/httplib.py", line 502, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port:
'My&Passw6 at sd-portal.prasentia.net'

Strangely enough, the URL is not considered invalid by Python 2.4
(compiled fresh on WBEL), but I get 401 Unauthorized even though I can
cut/paste the URL into my browser (firefox 1.0) and I'm given
access...so I *know* it is not a typo:

Traceback (most recent call last):
  File "./testCondon.py", line 8, in ?
    print test.ReturnSimpleInt()
  File "/usr/lib/python2.4/xmlrpclib.py", line 1096, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.4/xmlrpclib.py", line 1383, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.4/xmlrpclib.py", line 1137, in request
    headers
xmlrpclib.ProtocolError: <ProtocolError for
  3tier:My&Passw6 at www.server.net/Forecast: 401 Unauthorized>

The _only_ thing I was able to find in google about this is this one
bug:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=944396&group_id=5470

which seems to indicate that username:password at hostname is not
*actually* an RFC valid syntax. However the xmlrpclib documenation
clearly indicates that that is *the* syntax to use:

http://docs.python.org/lib/module-xmlrpclib.html

What gives? What is the "right" way to do it?

Thanks,
Paul




More information about the Python-list mailing list