提供的 URI 方案“https"无效;调用 Web 服务时预期为“http" [英] The provided URI scheme 'https' is invalid; expected 'http' when calling web service

查看:37
本文介绍了提供的 URI 方案“https"无效;调用 Web 服务时预期为“http"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:

提供的 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); 上抛出错误.

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

推荐答案

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

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

这篇关于提供的 URI 方案“https"无效;调用 Web 服务时预期为“http"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆