public override string ToString() { StringBuilder builder = new StringBuilder(); builder.AppendLine(base.ToString()); if (MetadataImportErrors != null) { builder.AppendLine("Metadata Import Errors:"); builder.AppendLine(DynamicProxyFactory.ToString( MetadataImportErrors)); } if (CodeGenerationErrors != null) { builder.AppendLine("Code Generation Errors:"); builder.AppendLine(DynamicProxyFactory.ToString( CodeGenerationErrors)); } if (CompilationErrors != null) { builder.AppendLine("Compilation Errors:"); builder.AppendLine(DynamicProxyFactory.ToString( CompilationErrors)); } return(builder.ToString()); }
public static void Test() { ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(SkipCertValidation); string baseAddress = "https://" + Environment.MachineName + ":8888/Service"; ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress)); host.AddServiceEndpoint(typeof(ITest), GetBinding(), ""); host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpsGetEnabled = true }); host.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom; host.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new MyPasswordValidator(); host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.UseAspNetRoles; host.Open(); Console.WriteLine("Host opened"); DynamicProxyFactory factory = new DynamicProxyFactory(baseAddress + "?wsdl"); DynamicProxy proxy = factory.CreateProxy("ITest"); ClientCredentials credentials = proxy.GetProperty("ClientCredentials") as ClientCredentials; credentials.UserName.UserName = "******"; credentials.UserName.Password = "******"; Console.WriteLine(proxy.CallMethod("Hello")); Console.Write("Press ENTER to close the host"); Console.ReadLine(); host.Close(); }