static void HostWithOldHost()
 {
     var repository = new ToDoMemoryRepository();
     repository.Add(new ToDo("Must learn HTTP better"));
     var instance = new TodoResource(repository);
     using (var host = new ServiceHost(instance))
     {
         var ep = host.AddServiceEndpoint(typeof(TodoResource), new HttpBinding(), "http://localhost:8080/todo2");
         ep.Behaviors.Add(new HttpBehavior());
         host.Open();
         ShowEndpointsOf(host);
         WaitForKey();
     }
 }
示例#2
0
        static void HostWithOldHost()
        {
            var repository = new ToDoMemoryRepository();

            repository.Add(new ToDo("Must learn HTTP better"));
            var instance = new TodoResource(repository);

            using (var host = new ServiceHost(instance))
            {
                var ep = host.AddServiceEndpoint(typeof(TodoResource), new HttpBinding(), "http://localhost:8080/todo2");
                ep.Behaviors.Add(new HttpBehavior());
                host.Open();
                ShowEndpointsOf(host);
                WaitForKey();
            }
        }
        static void HostWithHttpsEndpoint()
        {
            var repository = new ToDoMemoryRepository();
            repository.Add(new ToDo("Must learn HTTP better"));
            var instance = new TodoResource(repository);
            using (var host = new HttpServiceHost(instance, "http://localhost:8080/todo"))
            {
                
                host.AddServiceEndpoint(typeof(TodoResource), new HttpBinding(), "http://localhost:8080/todo");

                var binding = new HttpBinding(HttpBindingSecurityMode.Transport);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                host.AddServiceEndpoint(typeof(TodoResource), binding, "https://localhost:8435/todo");
                //host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser,StoreName.My,X509FindType.FindBySubjectName, "gaviao");
                host.Open();
                ShowEndpointsOf(host);
                WaitForKey();
            }
        }
示例#4
0
        static void HostWithHttpsEndpoint()
        {
            var repository = new ToDoMemoryRepository();

            repository.Add(new ToDo("Must learn HTTP better"));
            var instance = new TodoResource(repository);

            using (var host = new HttpServiceHost(instance, "http://localhost:8080/todo"))
            {
                host.AddServiceEndpoint(typeof(TodoResource), new HttpBinding(), "http://localhost:8080/todo");

                var binding = new HttpBinding(HttpBindingSecurityMode.Transport);
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                host.AddServiceEndpoint(typeof(TodoResource), binding, "https://localhost:8435/todo");
                //host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser,StoreName.My,X509FindType.FindBySubjectName, "gaviao");
                host.Open();
                ShowEndpointsOf(host);
                WaitForKey();
            }
        }