1

I am trying to consume services from a XMLRPC web service using python. The remote web server require authentication and ssl verification. To do this staff, I implemented a an xmlrpc client using xmlrpc.client as follows:

class HTTPSDigestAuthTransport:

    def request(self, host, handler, request_body, verbose=0):
        api_url = Setup.get_api_url()
        username = Setup.get_api_username()
        password = Setup.get_api_password()
        h = httplib2.Http()
        if verbose:
            h.debuglevel = 1
        h.add_credentials(username, password)
        h.disable_ssl_certificate_validation = True
        resp, content = h.request("https://" + api_url, "POST", body=request_body,
                              headers={'content-type': 'text/xml'})
        if resp.status != 200:
            raise ProtocolError("https://" + api_url, resp.status, resp.reason, None)
        p, u = getparser(0)
        p.feed(content)


# transport factory instance
transport = HTTPSDigestAuthTransport()

# url composition
url = "https://" + Setup.get_api_username() + ":" + Setup.get_api_password() + "@" + Setup.get_api_url()

# create the proxy
proxy = xmlrpc.client.ServerProxy(url, transport)
res = proxy.do_some_work()

The problem is that the instruction res = proxy.do_some_work() generates this error:

File "/usr/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python3.6/xmlrpc/client.py", line 1455, in __request
if len(response) == 1:

TypeError: object of type 'NoneType' has no len()

Is object of type 'NoneType' has no len() due the the response format? What can be the solution?

Mehdi Ben Hamida
  • 893
  • 4
  • 16
  • 38

0 Answers0