2013-08-15 11 views
13

Próbuję wywołać usługę sieciową programu SharePoint z przepływu pracy CRM przy użyciu niestandardowego kodu C#. Jednakże gdy uruchomię mój kod, pojawia się następujący błąd:Podany schemat adresu "https" jest nieprawidłowy; oczekiwany "http" podczas wywoływania usługi WWW

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

Oto kod naruszającym przepisy:

#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 

Błąd zostaje wrzucony na linii String response = client.CopyFolderContentsAcrossSites(sourceSiteURL, sourceFolderURL, destinationSiteURL, destinationFolderURL); gdzie metoda klienta nazywa.

Dzięki za wszelką pomoc,
Scott

+7

TransportCredentialOnly nie działa z "https". Dla "https" musisz użyć Transport lub TransportWithMessageCredential. –

+0

Dzięki, wypróbuję to i skontaktuję się z Tobą – Scott

+0

To zadziałało! Przełączyłem go na transport i działało bezbłędnie. Dzięki! – Scott

Odpowiedz

30

Zgodnie z dokumentacją BasicHttpSecurityMode, TransportCredentialOnly może być używany tylko z HTTP. W przypadku HTTPS musisz użyć albo Transport lub TransportWithMessageCredential.

Powiązane problemy