当前位置: 首页>>代码示例>>C#>>正文


C# WebServiceHost.Close方法代码示例

本文整理汇总了C#中System.ServiceModel.Web.WebServiceHost.Close方法的典型用法代码示例。如果您正苦于以下问题:C# WebServiceHost.Close方法的具体用法?C# WebServiceHost.Close怎么用?C# WebServiceHost.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Web.WebServiceHost的用法示例。


在下文中一共展示了WebServiceHost.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public async Task Run(string httpAddress, string listenToken)
        {
            using (var host = new WebServiceHost(this.GetType()))
            {
                var webHttpRelayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport,
                                                                  RelayClientAuthenticationType.RelayAccessToken)
                                                                 {IsDynamic = false};
                host.AddServiceEndpoint(this.GetType(),
                    webHttpRelayBinding,
                    httpAddress)
                    .EndpointBehaviors.Add(
                        new TransportClientEndpointBehavior(
                            TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken)));

                host.Open();

                Console.WriteLine("Copy the following address into a browser to see the image: ");
                Console.WriteLine(httpAddress + "/Image");
                Console.WriteLine();
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
        }
开发者ID:lokeshsp,项目名称:azure-servicebus-relay-samples,代码行数:25,代码来源:Program.cs

示例2: Run

        public async Task Run(string hostName, string listenToken)
        {
            string httpAddress = new UriBuilder("http", hostName, -1, "svc").ToString();
            using (var host = new WebServiceHost(GetType()))
            {
                host.AddServiceEndpoint(
                    GetType(),
                    new WebHttpRelayBinding(
                        EndToEndWebHttpSecurityMode.None,
                        RelayClientAuthenticationType.None) {IsDynamic = true},
                    httpAddress)
                    .EndpointBehaviors.Add(
                        new TransportClientEndpointBehavior(
                            TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken)));

                host.Open();

                Console.WriteLine("Starting a browser to see the image: ");
                Console.WriteLine(httpAddress + "/Image");
                Console.WriteLine();
                // launching the browser
                System.Diagnostics.Process.Start(httpAddress + "/Image");
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
        }
开发者ID:lokeshsp,项目名称:azure-servicebus-relay-samples,代码行数:28,代码来源:Program.cs

示例3: Main

		static void Main (string[] args) {
			LegoRestService DemoServices = new LegoRestService ();
			WebServiceHost _serviceHost = new WebServiceHost (DemoServices, new Uri ("http://localhost:8000/DEMOService"));
			_serviceHost.Open ();
			Console.ReadKey ();
			_serviceHost.Close ();
		}
开发者ID:ubuntuuser,项目名称:LegoRestService,代码行数:7,代码来源:LegoRestService.cs

示例4: Main

        static void Main(string[] args)
        {
            // Before running replace the servicebus namespace (next line) and REPLACESERVICEBUSKEY (app.config)
            string serviceNamespace = "jtarquino";
            string serviceBusKey = "REPLACEKEYHERE";
            Console.Write("Your Service Namespace: ");

            // Tranport level security is required for all *RelayBindings; hence, using https is required
            Uri address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "Timer");

            WebServiceHost host = new WebServiceHost(typeof(ProblemSolver), address);

            WebHttpRelayBinding binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);

            host.AddServiceEndpoint(
               typeof(IProblemSolver), binding, address)
                .Behaviors.Add(new TransportClientEndpointBehavior
                {
                    TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", serviceBusKey)
                });

            host.Open();
            Console.WriteLine(address + "CurrentTime");
            Console.WriteLine("Press ENTER to close");
            Console.ReadLine();

            host.Close();
        }
开发者ID:jtarquino,项目名称:ServiceBusDataService,代码行数:28,代码来源:Program.cs

示例5: Two

        private static void Two()
        {
            Console.WriteLine("Starting service...");

            // Configure the credentials through an endpoint behavior.
            TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
            relayCredentials.TokenProvider =
              TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "fBLL/4/+rEsCOiTQPNPS6DJQybykqE2HdVBsILrzMLY=");

            // Create the binding with default settings.
            WebHttpRelayBinding binding = new WebHttpRelayBinding();

            binding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.None;
            // Get the service address.
            // Use the https scheme because by default the binding uses SSL for transport security.
            Uri address = ServiceBusEnvironment.CreateServiceUri("https", "johnsonwangnz", "Rest");

            // Create the web service host.
            WebServiceHost host = new WebServiceHost(typeof(EchoRestService), address);
            // Add the service endpoint with the WS2007HttpRelayBinding.
            host.AddServiceEndpoint(typeof(IEchoRestContract), binding, address);

            // Add the credentials through the endpoint behavior.
            host.Description.Endpoints[0].Behaviors.Add(relayCredentials);

            // Start the service.
            host.Open();

            Console.WriteLine("Listening...");

            Console.ReadLine();
            host.Close();
        }
开发者ID:cleancodenz,项目名称:ServiceBus,代码行数:33,代码来源:Program.cs

示例6: Main

        static void Main(string[] args)
        {
            WebServiceHost webServiceHost = new WebServiceHost(typeof(PartyService.Service));

            WebHttpBinding serviceBinding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
            serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            ServiceEndpoint ep = webServiceHost.AddServiceEndpoint(
                typeof(PartyService.IService),
                serviceBinding,
                "http://localhost:8000/service");
            ep.Behaviors.Add(new PartyService.ProcessorBehaviour());

            WebHttpBinding staticBinding = new WebHttpBinding(WebHttpSecurityMode.None);
            ServiceEndpoint sep = webServiceHost.AddServiceEndpoint(
                typeof(PartyService.IStaticItemService),
                new WebHttpBinding(),
                "http://localhost:8000");

            webServiceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
            webServiceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new PartyService.Validator();
            webServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;

            webServiceHost.Open();
            Console.WriteLine("Service is running - press enter to quit");
            Console.ReadLine();
            webServiceHost.Close();
            Console.WriteLine("Service stopped");
        }
开发者ID:offspin,项目名称:building_blocks,代码行数:28,代码来源:Program.cs

示例7: Main

 static void Main(string[] args)
 {
     WebServiceHost host=new WebServiceHost(typeof(OperatingSystemService),new Uri("http://localhost:8013/RESTWebservice/"));
     host.Open();
     Console.ReadKey();
     host.Close();
 }
开发者ID:m-karimi,项目名称:Code-Samples,代码行数:7,代码来源:Program.cs

示例8: Main

        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8000/");
            ServiceHost selfHost = new WebServiceHost(typeof(MonitorService), baseAddress);

            try
            {
                // Step 3 Add a service endpoint.
                var t = new WebHttpBinding();

                selfHost.AddServiceEndpoint(typeof(IMonitorService), t, "test");
                WebHttpBehavior whb = new WebHttpBehavior();

                // Step 4 Enable metadata exchange.
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;

                selfHost.Description.Behaviors.Add(smb);

                // Step 5 Start the service.
                selfHost.Open();
                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press <ENTER> to terminate service.");
                Console.WriteLine();
                Console.ReadLine();

                // Close the ServiceHostBase to shutdown the service.
                selfHost.Close();
            }
            catch (CommunicationException ce)
            {
                Console.WriteLine("An exception occurred: {0}", ce.Message);
                selfHost.Abort();
            }
        }
开发者ID:Shamsterl,项目名称:SimpleSystemMonitor,代码行数:35,代码来源:Program.cs

示例9: Main

 static void Main(string[] args)
 {
     // var webServiceHost = new ServiceHost(typeof(Machine));
     var webServiceHost = new WebServiceHost(typeof(Machine), new Uri("http://localhost:8080/RESTWcf"));
     webServiceHost.Open();
     Console.ReadLine();
     webServiceHost.Close();
 }
开发者ID:JohanWe,项目名称:Code-Sample,代码行数:8,代码来源:Program.cs

示例10: Main

 static void Main(string[] args)
 {
     WebServiceHost wh = new WebServiceHost(typeof(HelloWorldService),new Uri(ServiceUri));
     wh.Open();
     Console.WriteLine("Service opened on {0}", ServiceUri);
     Console.WriteLine("Press any key to stop service...");
     Console.ReadKey();
     wh.Close();
 }
开发者ID:Redwan13,项目名称:wcf_nodewebkit_demo,代码行数:9,代码来源:Program.cs

示例11: Main

 public static void Main()
 {
     var host = new WebServiceHost(typeof(LicensewebService), new Uri("http://localhost:8000/"));
     var ep = host.AddServiceEndpoint(typeof(ILicensewebService), new WebHttpBinding(), "");
     host.Open();
     Console.WriteLine("Service running, press enter to quit");
     Console.ReadLine();
     host.Close();
 }
开发者ID:codeape2,项目名称:LWebService,代码行数:9,代码来源:ServiceHost.cs

示例12: Main

 private static void Main()
 {
     BindRequestToProcessors();
     _service = new WebServiceHost(typeof(JsonServicePerCall));
     _service.Open();
     Console.WriteLine("Sample REST Service is running");
     Console.WriteLine("Press any key to exit\n");
     Console.ReadKey();
     _service.Close();
 }
开发者ID:KaterinaShumskaya,项目名称:Nelibur,代码行数:10,代码来源:Program.cs

示例13: Main

 static void Main(string[] args)
 {
     WebService DemoServices = new WebService();
     WebHttpBinding binding = new WebHttpBinding();
     WebServiceHost serviceHost = new WebServiceHost(DemoServices, new Uri("http://localhost:8000/"));
     serviceHost.AddServiceEndpoint(typeof(IWebService), binding, "");
     serviceHost.Open();
     Console.ReadKey();
     serviceHost.Close();
 }
开发者ID:mpoulshock,项目名称:hammurabi,代码行数:10,代码来源:Program.cs

示例14: Main

        private static void Main(string[] args)
        {
            var service = new WebServiceHost(typeof(JsonServicePerCall));
            service.Open();

            Console.WriteLine("Service is running");
            Console.WriteLine("Press any key to exit\n");

            Console.ReadLine();
            service.Close();
        }
开发者ID:Nerielle,项目名称:NeliburSimpleApp,代码行数:11,代码来源:Program.cs

示例15: Main

        static void Main(string[] args)
        {
            WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8200/"));
            ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), "");

            host.Open();
            Console.WriteLine("Service is running");
            Console.WriteLine("Press enter to quit...");
            Console.ReadLine();
            host.Close();
        }
开发者ID:hornT,项目名称:CompPdu,代码行数:11,代码来源:Program.cs


注:本文中的System.ServiceModel.Web.WebServiceHost.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。