Skip to content

Instantly share code, notes, and snippets.

Created November 4, 2015 10:29
Show Gist options
  • Save anonymous/7a7ec32f2ce5cdfd0368 to your computer and use it in GitHub Desktop.
Save anonymous/7a7ec32f2ce5cdfd0368 to your computer and use it in GitHub Desktop.
EndpointAddress endpoint = new EndpointAddress("endpoint");
CustomBinding binding = new CustomBinding();
var security = TransportSecurityBindingElement.CreateUserNameOverTransportBindingElement();
security.IncludeTimestamp = false;
security.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Basic256;
security.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
var encoding = new TextMessageEncodingBindingElement();
encoding.MessageVersion = MessageVersion.Soap11;
var transport = new HttpsTransportBindingElement();
transport.MaxReceivedMessageSize = 20000000;
binding.Elements.Add(security);
binding.Elements.Add(encoding);
binding.Elements.Add(transport);
webservice service = new webservice(binding, endpoint);
cient.ClientCredentials.UserName.UserName = "user";
cient.ClientCredentials.UserName.Password = "pass";
cient.ClientCredentials.HttpDigest.ClientCredential.UserName = "user";
cient.ClientCredentials.HttpDigest.ClientCredential.Password = "pass";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment