2013-08-15 19 views
13

Sto provando a chiamare un servizio Web di SharePoint da un flusso di lavoro CRM utilizzando il codice C# personalizzato. Tuttavia quando ho eseguito il mio codice, ottengo il seguente errore:Lo schema URI fornito 'https' non è valido; "http" previsto quando si chiama il servizio web

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

ecco il codice incriminato:

#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 

L'errore si butta sulla linea String response = client.CopyFolderContentsAcrossSites(sourceSiteURL, sourceFolderURL, destinationSiteURL, destinationFolderURL); in cui il metodo del cliente viene chiamato.

Grazie per qualsiasi aiuto,
Scott

+7

TransportCredentialOnly non funziona con 'https'. Per "https" è necessario utilizzare Transport o TransportWithMessageCredential. –

+0

Grazie, proverò e tornerò da te – Scott

+0

Ha funzionato! L'ho acceso per il trasporto e ha funzionato perfettamente. Grazie! – Scott

risposta

30

Come per la documentazione per BasicHttpSecurityMode, TransportCredentialOnly possono essere utilizzati solo con HTTP. Per HTTPS è necessario utilizzare Transport o TransportWithMessageCredential.

Problemi correlati