2013-08-15 53 views
13

Tôi đang cố gắng gọi dịch vụ web SharePoint từ quy trình làm việc CRM bằng mã C# tùy chỉnh. Tuy nhiên khi tôi chạy mã của tôi, tôi nhận được lỗi sau:Lược đồ URI được cung cấp 'https' không hợp lệ; dự kiến ​​'http' khi gọi dịch vụ web

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

Đây là mã vi phạm:

#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 

Các lỗi được ném trên dòng String response = client.CopyFolderContentsAcrossSites(sourceSiteURL, sourceFolderURL, destinationSiteURL, destinationFolderURL); nơi phương pháp của khách hàng được gọi.

Nhờ sự giúp đỡ,
Scott

+7

TransportCredentialOnly không hoạt động với 'https'. Đối với 'https', bạn cần sử dụng Transport hoặc TransportWithMessageCredential. –

+0

Cảm ơn, tôi sẽ thử điều này và lấy lại cho bạn – Scott

+0

Nó đã hoạt động! Tôi chuyển nó để vận chuyển và nó hoạt động hoàn hảo. Cảm ơn! – Scott

Trả lời

30

Theo tài liệu cho BasicHttpSecurityMode, TransportCredentialOnly chỉ có thể được sử dụng với HTTP. Đối với HTTPS, bạn phải sử dụng Transport hoặc TransportWithMessageCredential.

Các vấn đề liên quan