gpt4 book ai didi

python - 从 Python 连接到 Microsoft Dynamics CRM 2011 SDK

转载 作者:行者123 更新时间:2023-11-28 19:27:05 24 4
gpt4 key购买 nike

有没有人有幸使用 Python 连接到 Microsoft Dynamics CRM 2011 中的 2011 端点?我已经安装了 SUDS 并且可以获取 WSDL,但是服务调用返回 400 Bad Request。我确定这是因为我没有经过身份验证,但我不太确定如何使用原始 SOAP 进行身份验证。我知道 Girish's code sample但我对 SOAP 还不够熟悉,无法更进一步。

我看到这是被问到的 a year ago on SO但这个问题似乎是关于 NTLM 的。就我而言,我想使用 WS-Trust。

这是我得到的代码:

from suds.client import Client
import logging

logging.basicConfig(level=logging.INFO)

url = 'https://dev.crm.dynamics.com/XRMServices/2011/Discovery.svc?wsdl'
client = Client(url)

req = client.factory.create('ns3:RetrieveOrganizationsRequest')
accessTypes = client.factory.create('ns3:AccessType')
orgRel = client.factory.create('ns3:OrganizationRelease')
req.AccessType = accessTypes.Default
req.Release = orgRel.Current

headers = dict()
headers['Content-Type'] = 'application/soap+xml'
client.set_options(headers=headers)

resp = client.service.Execute(req)

最佳答案

如果不需要使用 SOAP——请考虑 RESTish Odata服务。我不是 Python 专家——但您可以在浏览器中运行 GET 请求,并使用调试器工具查看浏览器为 header 发送的内容,并在您的 Python 代码中模仿它。您还可以通过修改 Content-Type header 来选择服务返回的格式(JSON 或 XML)。

关于python - 从 Python 连接到 Microsoft Dynamics CRM 2011 SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7940650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com