C# 提供的 URI 方案“https”无效;调用 Web 服务时预期为“http”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18259364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 11:42:42  来源:igfitidea点击:

The provided URI scheme 'https' is invalid; expected 'http' when calling web service

c#wcfsharepointdynamics-crm-2011

提问by Scott

I am trying to call a SharePoint web service from a CRM workflow using custom C# code. However when I run my code, I get the following error:

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

The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via

The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via

Here is the offending code:

这是违规代码:

#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

The error gets thrown on the line String response = client.CopyFolderContentsAcrossSites(sourceSiteURL, sourceFolderURL, destinationSiteURL, destinationFolderURL);where the client's method is called.

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

Thanks for any help,
Scott

感谢您的帮助,
斯科特

采纳答案by Jim Rhodes

As per the documentation for BasicHttpSecurityMode, TransportCredentialOnlymay only be used with HTTP. For HTTPS you must use either Transportor TransportWithMessageCredential.

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