static void Main(string[] args) { try { SecuredMessageServiceClient ClientProxy = new SecuredMessageServiceClient(); ClientProxy.ClientCredentials.UserName.UserName = "******"; ClientProxy.ClientCredentials.UserName.Password = "******"; ClientProxy.SaySecuredMessage("Rameshkartik"); Console.WriteLine("Message Sent to SecuredMessage Service"); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { EndpointAddress endpoint = new EndpointAddress("http://localhost:8735/Rameshkartik/WCFSamples/SecuredMessageService"); WSHttpBinding binding = new WSHttpBinding(); binding.Security.Mode = SecurityMode.Message; binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; SecuredMessageServiceClient ProxyRefrence = new SecuredMessageServiceClient(binding, endpoint); ProxyRefrence.Open(); System.AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal); ProxyRefrence.SaySecuredMessage("Ramesh"); Console.WriteLine("Message Sent"); Console.ReadKey(); ProxyRefrence.Close(); }
static void Main(string[] args) { EndpointAddress endpoint = new EndpointAddress("http://localhost:8735/Rameshkartik/WCFSamples/SecuredMessageService"); WSHttpBinding binding = new WSHttpBinding(); binding.Security.Mode = SecurityMode.Message; binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; SecuredMessageServiceClient ProxyRefrence = new SecuredMessageServiceClient(binding, endpoint); ProxyRefrence.Open(); ProxyRefrence.SaySecuredMessage("Ramesh"); ChannelFactory <ISecuredMessageService> cf = new ChannelFactory <ISecuredMessageService>(binding, endpoint); cf.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation; ISecuredMessageService iServiceMethod = cf.CreateChannel(); iServiceMethod.LogMessage("Hi Hru"); //ProxyRefrence.LogMessage("Hi Howru"); Console.WriteLine("Message Sent"); Console.ReadKey(); ProxyRefrence.Close(); }