C# 使用CRM 2011 IFD连接组织服务

C# 使用CRM 2011 IFD连接组织服务,c#,dynamics-crm-2011,dynamics-crm,C#,Dynamics Crm 2011,Dynamics Crm,我只是想学习xRM。大多数时候,我都是在工作网络之外工作。(由于许多原因,我们的VPS并不总是按预期工作) 我通常可以从我的个人电脑使用IFD连接到我们的CRM。我想知道的是,我可以从我们的网络外部使用组织服务吗?如果是,你知道任何例子吗?还是与MS CRM网站上描述的标准方式相同 感谢您下面的复查说明了如何使用C#在IFD模式下连接到CRM。下面的复查说明了如何使用C#在IFD模式下连接到CRM。为了future-proof Andrii的答案,以下是链接文章中的示例代码: Uri organ

我只是想学习xRM。大多数时候,我都是在工作网络之外工作。(由于许多原因,我们的VPS并不总是按预期工作)

我通常可以从我的个人电脑使用IFD连接到我们的CRM。我想知道的是,我可以从我们的网络外部使用组织服务吗?如果是,你知道任何例子吗?还是与MS CRM网站上描述的标准方式相同


感谢您

下面的复查说明了如何使用C#在IFD模式下连接到CRM。

下面的复查说明了如何使用C#在IFD模式下连接到CRM。

为了future-proof Andrii的答案,以下是链接文章中的示例代码:

Uri organizationUriIFD = new Uri("https://[server]:[port]/XRMServices/2011/Organization.svc");

ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = "username";
credentials.UserName.Password = "password";

IServiceConfiguration<IOrganizationService> config = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationUriIFD);

using (Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(config, credentials))
{
  // This statement is required to enable early-bound type support.
  _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

  IOrganizationService _service = (IOrganizationService)_serviceProxy;

  WhoAmIResponse response = (WhoAmIResponse)_service.Execute(new WhoAmIRequest());
  Console.WriteLine(response.UserId.ToString());

  Console.ReadLine();
}
uriorganizationurifd=newuri(“https://[server]:[port]/XRMServices/2011/Organization.svc”);
ClientCredentials=新的ClientCredentials();
credentials.UserName.UserName=“UserName”;
credentials.UserName.Password=“Password”;
IServiceConfiguration config=ServiceConfigurationFactory.CreateConfiguration(OrganizationUriFd);
使用(Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy\u serviceProxy=新OrganizationServiceProxy(配置,凭据))
{
//此语句是启用早期绑定类型支持所必需的。
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(新的ProxyTypesBehavior());
IOR组织服务_服务=(IOR组织服务)_服务代理;
WhoAmIResponse=(WhoAmIResponse)\ u service.Execute(新的WhoAmIRequest());
Console.WriteLine(response.UserId.ToString());
Console.ReadLine();
}

对于未来证明安德烈的答案,以下是链接文章中的示例代码:

Uri organizationUriIFD = new Uri("https://[server]:[port]/XRMServices/2011/Organization.svc");

ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = "username";
credentials.UserName.Password = "password";

IServiceConfiguration<IOrganizationService> config = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationUriIFD);

using (Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(config, credentials))
{
  // This statement is required to enable early-bound type support.
  _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

  IOrganizationService _service = (IOrganizationService)_serviceProxy;

  WhoAmIResponse response = (WhoAmIResponse)_service.Execute(new WhoAmIRequest());
  Console.WriteLine(response.UserId.ToString());

  Console.ReadLine();
}
uriorganizationurifd=newuri(“https://[server]:[port]/XRMServices/2011/Organization.svc”);
ClientCredentials=新的ClientCredentials();
credentials.UserName.UserName=“UserName”;
credentials.UserName.Password=“Password”;
IServiceConfiguration config=ServiceConfigurationFactory.CreateConfiguration(OrganizationUriId);
使用(Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy\u serviceProxy=新的OrganizationServiceProxy(配置,凭据))
{
//此语句是启用早期绑定类型支持所必需的。
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(新的ProxyTypesBehavior());
IOR组织服务_服务=(IOR组织服务)_服务代理;
WhoAmIResponse=(WhoAmIResponse)\ u service.Execute(新的WhoAmIRequest());
Console.WriteLine(response.UserId.ToString());
Console.ReadLine();
}

谢谢安德烈。我一恢复网络连接就可以开始了。(是的,过去三天的服务中断了,太好了!!)谢谢安德烈。我一恢复网络连接就可以开始了。(是的,服务已经过去三天了,太好了,嗯!!)