Accediendo a servicios de Sharepoint por HTTPs

En un post anterior explico como configurar el HTTPs en los sitios de Sharepoint en este les explico el código de como consumirlo:
http://mteheran.wordpress.com/2014/01/05/configurando-https-en-sharepoint/

Primero debes instanciar estas reglas globales en nuestra clase donde estemos ejecutando cualquier servicio ya sea el List.asmx o el Copy.asmx:

 ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate);
 ServicePointManager.Expect100Continue = true;
 ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
 

Luego debemos crear nuestro punto de inicio y fin para el consumir el servicio

 BasicHttpBinding binding = new BasicHttpBinding();
 binding.MaxBufferSize = 99999999;
 binding.MaxReceivedMessageSize = 99999999;
 binding.Security.Mode = BasicHttpSecurityMode.Transport;
 binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
 binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
 binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
 binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
 

Luego configuramos el punto final y realizamos la logica que necesitamos esta es igual para el servicio Lists.asmx para este caso muestro el ejemplo de como se usa con el Copy.asmx y realizo la opción de leer un archivo.

<!-- wp:paragraph -->
<p>EndpointAddress endpoint = new EndpointAddress({Ursharepointl} + "/_vti_bin/Copy.asmx"));<br>using (CopySoapClient client = new CopySoapClient(binding, endpoint))<br>{<br>client.Endpoint.Address = new System.ServiceModel.EndpointAddress({Ursharepointl} + "/_vti_bin/Copy.asmx");<br>client.Endpoint.Contract.Name = "ws.App.SharePointDocuments.CopySoap";<br>client.Endpoint.Binding.Name = "basicHttpBinding";<br>client.Endpoint.Contract.ConfigurationName = "CopySoap";<br>NetworkCredential cred = new NetworkCredential(strUser, strPassWord);<br>client.ClientCredentials.Windows.ClientCredential = cred;<br>client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>client.Open();<br>string destinationUrl = {RutaArchivo} + file;<br>byte[] bitFile;<br>FieldInformation[] outFields;<br>uint ret = client.GetItem(destinationUrl, out outFields, out bitFile);<br>fileinfo.Content = bitFile;<br>fileinfo.Errors = "";<br>fileinfo.P8_Url = destinationUrl;<br>client.Close();</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>            }<br>
</code></p>
<!-- /wp:paragraph -->

Cualquier duda pueden dejarla en los comentarios.

Un comentario en «Accediendo a servicios de Sharepoint por HTTPs»

Los comentarios están cerrados.