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


C# WebServiceHost.Open方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            ItemCounter counter = new ItemCounter();

            using (WebServiceHost host = new WebServiceHost(new StreamingFeedService(counter), new Uri("http://localhost:8000/Service")))
            {
                WebHttpBinding binding = new WebHttpBinding();

                binding.TransferMode = TransferMode.StreamedResponse;
                host.AddServiceEndpoint(typeof(IStreamingFeedService), binding, "Feeds");

                host.Open();

                XmlReader reader = XmlReader.Create("http://localhost:8000/Service/Feeds/StreamedFeed");
                StreamedAtom10FeedFormatter formatter = new StreamedAtom10FeedFormatter(counter);

                Console.WriteLine("Reading stream from server");

                formatter.ReadFrom(reader);
                SyndicationFeed feed = formatter.Feed;

                foreach (SyndicationItem item in feed.Items)
                {
                    //This sample is implemented such that the server will generate an infinite stream of items;
                    //it only stops after the client reads 10 items
                    counter.Increment();
                }

                Console.WriteLine("CLIENT: read total of {0} items", counter.GetCount());
                Console.WriteLine("Press any key to terminate");
                Console.ReadLine();
            }
        }
开发者ID:ssickles,项目名称:archive,代码行数:33,代码来源:Program.cs

示例2: Start

        public void Start(string[] args)
        {
            HomeModule.Container = AppContext.Container;
            PackagesModule.Container = AppContext.Container;
            InstallationsModule.Container = AppContext.Container;
            LogModule.Container = AppContext.Container;
            ActionsModule.Container = AppContext.Container;
            ConfigurationModule.Container = AppContext.Container;

            Nancy.Json.JsonSettings.MaxJsonLength = 1024*1024*5; // 5mb max

            try
            {
                WebUiAddress = new Uri("http://localhost:9999/");
                _host = new WebServiceHost(new NancyWcfGenericService(), WebUiAddress);
                _host.AddServiceEndpoint(typeof (NancyWcfGenericService), new WebHttpBinding(), "");
                _host.Open();
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex, "could not start listening");
            }

            _logger.Info("Hosting Web interface on: " + WebUiAddress);
        }
开发者ID:andrewmyhre,项目名称:DeployD,代码行数:25,代码来源:ManagementInterfaceHost.cs

示例3: 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

示例4: 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

示例5: Start

        private static void Start(string[] args)
        {
            WebServicesImplementation PureCloudServices = new WebServicesImplementation();
            WebServiceHost _serviceHost = new WebServiceHost(PureCloudServices, new Uri(PureCloudServices.URL));

            _serviceHost.Open();
        }
开发者ID:MyPureCloud,项目名称:BridgeServerSqlRestConnector,代码行数:7,代码来源:Program.cs

示例6: 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

示例7: 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

示例8: 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

示例9: StartWebService

 public void StartWebService()
 {
     //BasicConfigurator.Configure( new PatternLayout("%d [%t] %-5p %c %m%n"), @".\test.txt");
     RestDemoServices DemoServices = new RestDemoServices();
     WebServiceHost _serviceHost = new WebServiceHost(DemoServices, new Uri(URL));
     _serviceHost.Open();
 }
开发者ID:Masterwow3,项目名称:PAWebService,代码行数:7,代码来源:WebService.cs

示例10: OnStart

        protected override void OnStart(string[] args)
        {
            var sn = "Facturador Fiscal Winks Hotel";

            try
            {
                Uri baseAddress = new Uri(ConfigurationManager.AppSettings["BaseAddress"]);

                var webHost = new WebServiceHost(typeof(ServiceSelector), baseAddress);
                var endpoint = webHost.AddServiceEndpoint(typeof(IServiceSelector), new WebHttpBinding(WebHttpSecurityMode.None), baseAddress);
                //add support for cors (both for the endpoint to detect and create reply)
                endpoint.Behaviors.Add(new CorsBehaviorAttribute());

                foreach (var operation in endpoint.Contract.Operations)
                {
                    //add support for cors (and for operation to be able to not
                    //invoke the operation if we have a preflight cors request)
                    operation.Behaviors.Add(new CorsBehaviorAttribute());
                }

                webHost.Open();
            }
            catch (Exception ex)
            {
                if (!EventLog.SourceExists(sn))
                    EventLog.CreateEventSource(sn, "Application");

                EventLog.WriteEntry(sn, ex.Message, EventLogEntryType.Error);
            }
        }
开发者ID:nescalante,项目名称:taxbillerservice,代码行数:30,代码来源:BillingService.cs

示例11: StartControlService

        static void StartControlService(ManualResetEvent quitEvent)
        {
            try {

                string uriStr = string.Format ("http://localhost:{0}/{1}"
                                              , Properties.Settings.Default.ControlServicePort
                                              , Properties.Settings.Default.ControlServicePath);

                System.Diagnostics.Debug.WriteLine (string.Format ("Starting control service ({0}) ..."), uriStr);

                ControlService crawlerControlService = new ControlService ();
                crawlerControlService.QuitEvent = quitEvent;

                var serviceHost = new WebServiceHost (crawlerControlService, new Uri (uriStr));

                serviceHost.Open ();

                System.Diagnostics.Debug.WriteLine (string.Format ("Control service running."));

            } catch (Exception ex) {

                LogEx (ex);
                throw;
            }
        }
开发者ID:jaensen,项目名称:graph-crawler,代码行数:25,代码来源:Program.cs

示例12: 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

示例13: Create

 public static WebServiceHost Create(Uri baseUri, AppDelegate app)
 {
     var host = new WebServiceHost(new GateWcfService(app), baseUri);
     host.AddServiceEndpoint(typeof (GateWcfService), new WebHttpBinding(), "");
     host.Open();
     return host;
 }
开发者ID:bvanderveen,项目名称:gate,代码行数:7,代码来源:GateWcfService.cs

示例14: Main

        static void Main()
        {
            //Create Users
            UserDB.AddUser(new User("u1", "p1","1"));
            UserDB.AddUser(new User("u2", "p2","2"));
            UserDB.AddUser(new User("u3", "p3","3"));

            //Start BackOfficeService
            var backOfficeCallBackServiceHost = new WebServiceHost(typeof(BackOfficeCallBackService));
            backOfficeCallBackServiceHost.Open();

            //Start REST WebSiteService
            var webSiteServer = new WebServiceHost(typeof(WebSiteService));
            webSiteServer.Open();

            //Create timer to check messageQueue Outbox
            var myTimer = new Timer();
            myTimer.Elapsed += LookForDownloadReady;
            myTimer.Interval = 5;
            myTimer.Enabled = true;

            Console.ReadLine();

            //Meter aqui os closes dos servicos nos fim
        }
开发者ID:njfsilva,项目名称:RememberVinilWebStore,代码行数:25,代码来源:Program.cs

示例15: OnStart

 protected override void OnStart(string[] args)
 {
     var host = new WebServiceHost(new NancyWcfGenericService(),
                       new Uri("http://localhost:1234/base/"));
      host.AddServiceEndpoint(typeof(NancyWcfGenericService), new WebHttpBinding(), "");
      host.Open();
 }
开发者ID:nickgodsland,项目名称:ContinuousDeployment-TechTalk,代码行数:7,代码来源:Service1.cs


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