Plugins 从CRM沙盒插件OnPremise调用外部WCF服务(使用生成的客户端)失败

Plugins 从CRM沙盒插件OnPremise调用外部WCF服务(使用生成的客户端)失败,plugins,dynamics-crm,sandbox,dynamics-crm-365,Plugins,Dynamics Crm,Sandbox,Dynamics Crm 365,如何在插件中调用HTTPS WCF web服务,插件程序集在沙盒模式下注册。我得到System.Security.SecurityExceptionexception,有人能提供所有https web服务的方式吗。我的代码如下: BasicHttpBinding myBinding = new BasicHttpBinding(); myBinding.MaxReceivedMessageSize = Int32.MaxValue; myBinding.Name = “basicHttpBind

如何在插件中调用HTTPS WCF web服务,插件程序集在沙盒模式下注册。我得到
System.Security.SecurityException
exception,有人能提供所有https web服务的方式吗。我的代码如下:

BasicHttpBinding myBinding = new BasicHttpBinding();
myBinding.MaxReceivedMessageSize = Int32.MaxValue;
myBinding.Name = “basicHttpBinding”;
if (EndPoint.ToLower().Contains(“https://”))
{
//Throwing exception here – System.Security.SecurityException exception,
ServicePointManager.ServerCertificateValidationCallback += (sendr, cert, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)768 | (SecurityProtocolType)3072 | (SecurityProtocolType)192;
myBinding.Security.Mode = BasicHttpSecurityMode.Transport;
}
else
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
myBinding.Security.Mode = BasicHttpSecurityMode.None;
}
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
EndpointAddress endPointAddress = new EndpointAddress(EndPoint);
WebIALClient myClient = new WebIALClient(myBinding, endPointAddress)

因为您是本地版本,所以可以在非沙盒模式下注册插件程序集。ie
隔离模式=无
以克服此类错误

如果您想使用沙箱模式,请尝试使用
WebClient
类来调用WCF服务调用


您可以尝试并包括:
使用System.Web.Http.Cors

  [EnableCors(origins: "*", headers: "*", methods: "*")]

  [Route("api/ConvertUpload/{env}/{id}")]

  public string Get(string env, string id)
  {

      return "hi";
  }

您可能必须使用@Arun提到的WebClient

谢谢@Arun-但是我如何在这里传递requestParameter?DownloadData只接受uri地址,它没有任何重载函数来接受requestparam?即使在隔离模式“无”下注册插件程序集,也会遇到同样的问题。@user222419此讨论可能会有所帮助-
  [EnableCors(origins: "*", headers: "*", methods: "*")]

  [Route("api/ConvertUpload/{env}/{id}")]

  public string Get(string env, string id)
  {

      return "hi";
  }