有人将soap.py 或suds 与python-ntlm 结合起来吗?

发布于 2024-08-26 17:41:39 字数 371 浏览 14 评论 0原文

我想用 suds 或soap.py 替换应用程序当前(严重损坏且粗劣)基于 cURL(基于 cURL 命令行!)的 SOAP 客户端。问题是,我们必须联系 MS CRM 服务,因此必须使用 NTLM。由于多种原因,NTLM 代理使用起来有点麻烦,所以我正在研究 python-ntlm 来提供这种支持。

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

编辑

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苏佲洛 2024-09-02 17:41:39

Suds 自 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

尝试使用以下代码段,如所述 此处

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

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)
盗心人 2024-09-02 17:41:39

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

类似...

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

#insecure 用于自签名证书

Another approach would be to call your curl command during soap exceptions and then initiate a retry.

something like...

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

#insecure is used for self signed certs

夜无邪 2024-09-02 17:41:39

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

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

You can use CNTLM as a local proxy service which will handle all the NTLM authentication calls. Then you just reference the local CNTLM proxy IP and port with no authentication using soapy or urllib2... whatever really.

I've yet to find a python library that deals with complex proxies well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文