Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. client.ClientCredentials.UserName.UserName = "myUserName";
  2. client.ClientCredentials.UserName.Password = "myPassword";
  3. string anything = client.getValue(@"anyParam..");
  4.  
  5. <basicHttpBinding>
  6. <binding name="ServiceNameHereServiceBinding" >
  7. <security mode="TransportCredentialOnly">
  8. <transport clientCredentialType="Basic" proxyCredentialType="None"
  9. realm="">
  10. </transport>
  11. </security>
  12. </binding>
  13. </basicHttpBinding>
  14.  
  15. // Assign client.ClientCredentials.UserName.UserName and client.ClientCredentials.UserName.Password
  16. SetupClientAuthentication();
  17.  
  18. HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
  19.  
  20. httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " +
  21. Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName + ":" +
  22. client.ClientCredentials.UserName.Password));
  23.  
  24. using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
  25. {
  26. OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
  27. httpRequestProperty;
  28.  
  29. // Invoke client
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement