动力学365:为什么我得到“ Xrm.sdk wsdl” .NET6控制台客户端的错误?
Mac OS,.NET6,C#10.0。
我总是在.NET Framework平台上为MS Dynamics 365创建控制台客户端,没有问题。但是现在,我需要在.NET Core或更新的平台上进行相同的操作(因为稍后需要将其放入Docker容器中)。在这种情况下,我尝试使用.net6。
我创建了新的控制台应用程序,并添加了Nuget软件包:
Microsoft.poperplatform.datavers.client
v0.6.6system.configuration.configurationmanager
v6.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.servicemodel- 。 pirinives v4.9.0
我的简单program.cs
文件:
using System.Net;
using System.ServiceModel.Description;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Client;
namespace ConsoleAppExample
{
internal class Program
{
static void Main(string[] args)
{
Console.Title = "CRM console client";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var orgServiceUrl = "http://dev-crm-app02/MyCompany/XRMServices/2011/Organization.svc";
var crmUserLogin = "myLogin";
var crmUserPassword = "myPassword";
var credentials = new ClientCredentials();
credentials.UserName.UserName = crmUserLogin;
credentials.UserName.Password = crmUserPassword;
try
{
using (var orgService = new OrganizationServiceProxy(new Uri(orgServiceUrl),
null, credentials, null))
{
RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse =
(RetrieveVersionResponse) orgService.Execute(versionRequest);
WhoAmIRequest whoAmIRequest = new WhoAmIRequest();
WhoAmIResponse whoAmIResponse = (WhoAmIResponse) orgService.Execute(whoAmIRequest);
Console.WriteLine($"\nOrganizationService: {orgServiceUrl}");
Console.WriteLine($"CRM version: {versionResponse.Version}");
Console.WriteLine($"User login: {crmUserLogin}");
Console.WriteLine($"\nOrganizationId: {whoAmIResponse.OrganizationId}");
Console.WriteLine($"BusinessUnitId: {whoAmIResponse.BusinessUnitId}");
Console.WriteLine($"UserId: {whoAmIResponse.UserId}");
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message); // Xrm.Sdk WSDL
if (ex.InnerException != null)
{
Console.WriteLine(ex.InnerException.Message);
}
Console.ResetColor();
}
Console.WriteLine("\nPress ENTER for exit...");
Console.ReadLine();
}
}
}
但是当我运行应用程序时,我会得到错误:
xrm.sdk wsdl
为什么会发生以及如何解决?
Mac OS, .Net6, C# 10.0.
I always created console clients for MS Dynamics 365 on .Net Framework Platform without problems. But now I need to do the same on .Net Core or newer platform (because I need to put it into Docker container later). At this case I try to use .Net6.
I created new console application and added the NuGet packages:
Microsoft.PowerPlatform.Dataverse.Client
v0.6.6System.Configuration.ConfigurationManager
v6.0.0System.ServiceModel.Primitives
v4.9.0
My simple Program.cs
file:
using System.Net;
using System.ServiceModel.Description;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Client;
namespace ConsoleAppExample
{
internal class Program
{
static void Main(string[] args)
{
Console.Title = "CRM console client";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var orgServiceUrl = "http://dev-crm-app02/MyCompany/XRMServices/2011/Organization.svc";
var crmUserLogin = "myLogin";
var crmUserPassword = "myPassword";
var credentials = new ClientCredentials();
credentials.UserName.UserName = crmUserLogin;
credentials.UserName.Password = crmUserPassword;
try
{
using (var orgService = new OrganizationServiceProxy(new Uri(orgServiceUrl),
null, credentials, null))
{
RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse =
(RetrieveVersionResponse) orgService.Execute(versionRequest);
WhoAmIRequest whoAmIRequest = new WhoAmIRequest();
WhoAmIResponse whoAmIResponse = (WhoAmIResponse) orgService.Execute(whoAmIRequest);
Console.WriteLine(quot;\nOrganizationService: {orgServiceUrl}");
Console.WriteLine(quot;CRM version: {versionResponse.Version}");
Console.WriteLine(quot;User login: {crmUserLogin}");
Console.WriteLine(quot;\nOrganizationId: {whoAmIResponse.OrganizationId}");
Console.WriteLine(quot;BusinessUnitId: {whoAmIResponse.BusinessUnitId}");
Console.WriteLine(quot;UserId: {whoAmIResponse.UserId}");
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message); // Xrm.Sdk WSDL
if (ex.InnerException != null)
{
Console.WriteLine(ex.InnerException.Message);
}
Console.ResetColor();
}
Console.WriteLine("\nPress ENTER for exit...");
Console.ReadLine();
}
}
}
But when I run my application I get the error:
Xrm.Sdk WSDL
Why does it happen and how can I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
组织服务客户端被弃用,不直接支持网络核心。
使用DataVerse ServiceClient连接时,连接字符串或ServiceClient构造器是唯一支持的方法。
也就是说,由于基础身份验证堆栈的变化,ONPREM并没有得到很好的支持。
当前最好的支持功能是通过PREM上的ADF和自定义验证处理程序使用OAuth。
Dataverse Service客户端的用户编写了一个扩展名,它添加了对Net Core的AD和WSTRUST支持,但它不是MS分布的一部分。
您可以在Dataverse ServiceClient GitHub站点问题委员会板上找到指向它的链接
https://github.com/github.com/microsoft/microsoft/microsoft/microsoft/poperplatform-dataaverform-dataaverform-dataaverform-dataaverform-dataaverform-dataaverforf >
Organization service client is deprecated and is not supported directly on net core.
When connecting using the dataverse serviceclient, connection string or serviceclient constructor is the only supported way.
That said onprem is not well supported due to the changes I the underlying authentication stack.
Best currently possible supported feature is to use oAuth via adfs on prem with a custom auth handler.
There is an extension written by a user of the dataverse service client that adds AD and WSTrust support for net core, but it is not part of the MS distribution.
You can find a link to it on the dataverse serviceclient GitHub site issues board under the AD onPrem support topic
https://github.com/microsoft/PowerPlatform-DataverseServiceClient/issues/110
如果可能的话,使用Dataverse Service客户端连接到.NET 6的本地实例。如果要使用连接字符串连接:
如果您使用custom tokenProviderFunction使用ADFS 2016,也有可能连接。
配置非常冗长,但在本文中详细撰写:使用Dataverse Service Client连接到OnPrem Dynamics 365 CRM(来自.net 6+)以及代码示例
Connecting to on-premises instance from .NET 6 using Dataverse Service Client if possible. If you want to connect using connection string:
There is also possibility to connect if you are using ADFS 2016 using custom tokenProviderFunction.
Configuration is quite lengthy but written in detail at this article: Using Dataverse Service Client to connect to OnPrem Dynamics 365 CRM (From .NET 6+) along with code examples on github.