views:

213

answers:

1

I'd like to replace an app's current (badly busted and crufty) cURL-based (cURL command-line based!) SOAP client with suds or soap.py. Trouble is, we have to contact an MS CRM service, and therefore must use NTLM. For a variety of reasons the NTLM proxy is a bit of a pain to use, so I'm looking into python-ntlm to provide that support.

Can suds or soap.py be made to use this authentication method? If so, how? If not, any other suggestions would be fantastic.

Edit

As noted below, suds already supports python-ntlm out of the box.

+3  A: 

Suds was fixed to support it since 0.3.8.

Sources of python-suds-0.3.9\suds\transport\https.py says:

class WindowsHttpAuthenticated(HttpAuthenticated):
    """
    Provides Windows (NTLM) http authentication.
    @ivar pm: The password manager.
    @ivar handler: The authentication handler.
    """

    def u2handlers(self):
        # try to import ntlm support  
        try:
            from ntlm import HTTPNtlmAuthHandler
        except ImportError:
            raise Exception("Cannot import python-ntlm module")
        handlers = HttpTransport.u2handlers(self)
        handlers.append(HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.pm))
        return handlers

Try with the following snippet as described here:

from suds.transport.https import WindowsHttpAuthenticated
ntlm = WindowsHttpAuthenticated(username='xx', password='xx')
client = Client(url, transport=ntlm)
systempuntoout
I'll edit the question right away, but I've tried this and I get timeouts trying to connect to the server, or Error 54 - connection reset by peer.The service continues to work by way of cURL, though.
Chris R
Which server are you trying to connect?A local one?Do you see client calls on server log?
systempuntoout
Regrettably, no; I'm connecting to our client's Microsoft CRM metadata service. It's a pain in the ass, because it's managed by a third-party consulting firm.
Chris R