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

左心房为你撑大大i 提交于 2019-11-28 02:43:58

问题


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:

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.

Thanks for any help,
Scott


回答1:


As per the documentation for BasicHttpSecurityMode, TransportCredentialOnly may only be used with HTTP. For HTTPS you must use either Transport or TransportWithMessageCredential.



来源:https://stackoverflow.com/questions/18259364/the-provided-uri-scheme-https-is-invalid-expected-http-when-calling-web-ser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!