提供的URI方案“https”无效;调用Web服务时需要'http'

时间:2013-08-15 18:36:29

标签: c# wcf sharepoint dynamics-crm-2011

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

The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: 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);上抛出错误。

感谢您的帮助,
斯科特

1 个答案:

答案 0 :(得分:32)

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