c# - 提供的 URI 方案 'https' 无效;调用网络服务时预期为 'http'

标签 c# wcf sharepoint dynamics-crm-2011

我正在尝试使用自定义 C# 代码从 CRM 工作流调用 SharePoint 网络服务。但是,当我运行我的代码时,出现以下错误:

提供的 URI 方案“https”无效;预期'http'。 参数名称:via

这是有问题的代码:

#region Set up security binding and service endpoint
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Ntlm;
EndpointAddress endpoint = new EndpointAddress(endpointAddress);
#endregion

#region Create the client and supply appropriate credentials
CopySPContents.CopyService.SharepointFileServiceClient client = new CopySPContents.CopyService.SharepointFileServiceClient(binding, endpoint);              
client.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;              
#endregion

#region Call the web service and trace its response
String response = client.CopyFolderContentsAcrossSites(sourceSiteURL, sourceFolderURL, destinationSiteURL, destinationFolderURL);
#endregion

错误在调用客户端方法的 String response = client.CopyFolderContentsAcrossSites(sourceSiteURL, sourceFolderURL, destinationSiteURL, destinationFolderURL); 行上抛出。

感谢您的帮助,
斯科特

最佳答案

根据 BasicHttpSecurityMode 的文档,TransportCredentialOnly 只能与 HTTP 一起使用。对于 HTTPS,您必须使用 TransportTransportWithMessageCredential

关于c# - 提供的 URI 方案 'https' 无效;调用网络服务时预期为 'http',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18259364/

相关文章:

c# - 尝试将 Quartz.NET 与 oWin 一起使用时出现 Quartz.Simpl.JsonObjectSerializer 错误

c# - 如何在 WebAPI 上实现 SOAP 服务

.net - Redis 用于频繁更改的市场信息

c# - 在哪里使用 MVVM 中的 Web 服务?

JQuery ReplaceWith() 函数混淆

jQuery 嵌套数组

c# - 在实时服务器上发送电子邮件时出错

c# - 仅添加新方法而不添加数据时使用什么 OOP 模式?

c# - 如何使用 Open XML 将超链接添加到 Word docx 中?

C# : Show dialog on UI thread from another thread