【问题标题】:Has anyone combined soap.py or suds with python-ntlm?有没有人将soap.py或suds与python-ntlm结合起来?
【发布时间】:2010-03-25 14:57:18
【问题描述】:

我想用 suds 或 soap.py 替换一个应用当前(严重破坏和笨拙)基于 cURL(基于 cURL 命令行!)的 SOAP 客户端。麻烦的是,我们必须联系 MS CRM 服务,因此必须使用 NTLM。由于各种原因,NTLM 代理使用起来有点麻烦,所以我正在寻找python-ntlm 来提供这种支持。

可以让 suds 或 soap.py 使用这种身份验证方法吗?如果是这样,怎么做?如果没有,任何其他建议都会很棒。

编辑

如下所述,suds 已经支持 python-ntlm 开箱即用。

【问题讨论】:

    标签: python soap ntlm suds soappy


    【解决方案1】:

    Suds 是 fixed 从 0.3.8 开始支持它。

    python-suds-0.3.9\suds\transport\https.py 的来源说:

    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
    

    按照here 的描述尝试以下 sn-p:

    from suds.transport.https import WindowsHttpAuthenticated
    ntlm = WindowsHttpAuthenticated(username='xx', password='xx')
    client = Client(url, transport=ntlm)
    

    【讨论】:

    • 我将立即编辑问题,但我已经尝试过,但尝试连接服务器时出现超时,或错误 54 - 对等方重置连接。不过,该服务继续通过 cURL 工作。
    • 您要连接哪台服务器?本地服务器?您是否在服务器日志中看到客户端调用?
    • 很遗憾,没有;我正在连接到我们客户的 Microsoft CRM 元数据服务。这很麻烦,因为它是由第三方咨询公司管理的。
    【解决方案2】:

    另一种方法是在肥皂异常期间调用您的 curl 命令,然后启动重试。

    类似...

    curl -x websenseproxy:8080 --ntlm -U domain\user:password --insecure https://blah.com/prod/webservice.asmx?WSDL
    

    #insecure 用于自签名证书

    【讨论】:

      【解决方案3】:

      您可以将 CNTLM 用作本地代理服务,该服务将处理所有 NTLM 身份验证调用。然后,您只需引用本地 CNTLM 代理 IP 和端口,无需使用 soapy 或 urllib2 进行身份验证......不管是什么。

      我还没有找到一个可以很好地处理复杂代理的python库。

      【讨论】:

        猜你喜欢
        • 2011-07-31
        • 2012-01-02
        • 2011-08-24
        • 2015-04-05
        • 1970-01-01
        • 2013-12-28
        • 1970-01-01
        • 2011-01-05
        • 1970-01-01
        相关资源
        最近更新 更多