Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public int Test()
  2. {
  3. int p = 0;
  4. try
  5. {
  6. BasicHttpBinding binding = new BasicHttpBinding();
  7. binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
  8. binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
  9. EndpointAddress endpoint =
  10. new EndpointAddress(SPContext.Current.Web.Url + "/_vti_bin/TestWCF.svc");
  11. AjaxWCF.Test.WCFServiceClient proxy = new Test.WCFServiceClient(binding,endpoint);
  12. proxy.ClientCredentials.Windows.AllowedImpersonationLevel =
  13. System.Security.Principal.TokenImpersonationLevel.Impersonation;
  14.  
  15. //Call web service.
  16. string [] pow = proxy.GetItems();
  17.  
  18. //Refresh the UI.
  19. foreach (string i in pow)
  20. {
  21. p++;
  22. }
  23. }
  24. catch (Exception exc)
  25. {
  26.  
  27. throw;
  28. }
  29. return p;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement