我正在尝试使用 SOAPUI 调用 MSCRM 365 Web 服务,这是我到目前为止所做的
- 从我的 cRM 实例下载的组织 WSDL
- 在 SOAPUI 中上传
- 添加了三个标头参数 - Content-Type、SOAPAction 和 Accept
- 在请求属性中添加了用户名和密码
每当我向 MSCRM 发送请求时,我都会收到“HTTP ERROR 401 - Unauthorized: Access is denied”
有人有想法么?
谢谢,尼特什
我正在尝试使用 SOAPUI 调用 MSCRM 365 Web 服务,这是我到目前为止所做的
每当我向 MSCRM 发送请求时,我都会收到“HTTP ERROR 401 - Unauthorized: Access is denied”
有人有想法么?
谢谢,尼特什
由于这是 Dynamics 365,它不使用用户名/密码进行身份验证。相反,您需要使用 OAuth,如链接中所示
https://msdn.microsoft.com/en-us/library/gg327838.aspx
// TODO Substitute your correct CRM root service address,
string resource = "https://mydomain.crm.dynamics.com";
// TODO Substitute your app registration values that can be obtained after you
// register the app in Active Directory on the Microsoft Azure portal.
string clientId = "e5cf0024-a66a-4f16-85ce-99ba97a24bb2";
string redirectUrl = "http://localhost/SdkSample";
// Authenticate the registered application with Azure Active Directory.
AuthenticationContext authContext =
new AuthenticationContext("https://login.windows.net/common", false);
AuthenticationResult result = authContext.AcquireToken(resource, clientId, new
Uri(redirectUrl));
在消息请求中使用访问令牌:
using (HttpClient httpClient = new HttpClient())
{
httpClient.Timeout = new TimeSpan(0, 2, 0); // 2 minutes
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", result.AccessToken);
另一种选择是从 Xrm.Client 转移到 Xrm.Tools.Connection。请参阅本网站中的示例。