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


C# ServiceHost.AddDefaultEndpoints方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8080/Service");

            // Create the ServiceHost.
            using (ServiceHost host = new ServiceHost(typeof(CounterService), baseAddress))
            {
                // Enable metadata publishing.
                //ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                //smb.HttpGetEnabled = true;
                //smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;

                //host.Description.Behaviors.Add(smb);

                host.AddDefaultEndpoints();

                //var wsContract = new ContractDescription("WSHttpDefault");

                //var wsEndpoint = new ServiceEndpoint(

                // Open the ServiceHost to start listening for messages. Since
                // no endpoints are explicitly configured, the runtime will create
                // one endpoint per base address for each service contract implemented
                // by the service.
                host.Open();

                Console.WriteLine("The service is ready at {0}", baseAddress);
                Console.WriteLine("Press <Enter> to stop the service.");
                Console.ReadLine();

                // Close the ServiceHost.
                host.Close();
            }
        }
开发者ID:dharnitski,项目名称:BasicVsWs,代码行数:34,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            //ServiceHost myHost = new ServiceHost(typeof(WCFService));

            ServiceHost myHost = new ServiceHost(typeof(WCFService),
                new Uri("http://localhost:9003/AI3"),
                new Uri("net.tcp://localhost:9004/AI4"));

            myHost.AddDefaultEndpoints();

            myHost.AddServiceEndpoint(typeof(IWCFService), new BasicHttpBinding(), "http://localhost:9001/AI");
            myHost.AddServiceEndpoint(typeof(IWCFService), new NetTcpBinding(), "net.tcp://localhost:9002/");

            ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
            behavior.HttpGetUrl = new Uri("http://localhost:8090/WCFService");
            behavior.HttpGetEnabled = true;

            myHost.Description.Behaviors.Add(behavior);

            try
            {
                myHost.Open();
                Console.WriteLine("Service is worked ! Status : " + myHost.State);

                foreach (ServiceEndpoint ep in myHost.Description.Endpoints)
                {
                    Console.WriteLine("A : {0} - B : {1} - C : {2}", ep.Address, ep.Binding.Name, ep.Contract.Name);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }
开发者ID:abdurrahman,项目名称:CustomWCFService,代码行数:35,代码来源:Program.cs

示例3: GameServerForm_Load

        private void GameServerForm_Load(object sender, EventArgs e)
        {
            statusList.Items.Clear();

            statusList.Items.Add("Initializing");

            host = new ServiceHost(typeof(GameService), baseAddress);
            host.AddDefaultEndpoints();

            statusList.Items.Add("Host started");
        }
开发者ID:cdkmoose,项目名称:ShowDownSharp,代码行数:11,代码来源:GameServerForm.cs

示例4: OnStart

        protected override void OnStart(string[] args)
        {
            if (myHost != null)
            {
                myHost.Close();
            }

            // Create the host and specify a URL for an HTTP binding.
            myHost = new ServiceHost(typeof(MathService),
                new Uri("http://localhost:8080/MathServiceLibrary"));
            myHost.AddDefaultEndpoints();

            // Open the host.
            myHost.Open();
        }
开发者ID:usedflax,项目名称:flaxbox,代码行数:15,代码来源:MathWinService.cs

示例5: OnStart

        protected override void OnStart(string[] args) {
            if (myHost != null) {
                myHost.Close();
                myHost = null;            
            }
            Uri address = new Uri("http://localhost:8080/MathServiceLibrary");
            myHost = new ServiceHost(typeof(MathService), address);

            
            //BasicHttpBinding binding = new BasicHttpBinding();
            //Type contract = typeof(IBasicMath);
            //myHost.AddServiceEndpoint(contract, binding, address);


            myHost.AddDefaultEndpoints();

            myHost.Open();

        }
开发者ID:Geronimobile,项目名称:DotNetExamIntro,代码行数:19,代码来源:Service1.cs

示例6: Main

        static void Main(string[] args)
        {
            using (var host = new ServiceHost(
                typeof(EchoService),
                new Uri("http://localhost:8081/Echo")))
            {
                host.AddServiceEndpoint(new UdpDiscoveryEndpoint());
                host.AddDefaultEndpoints();
                host.Open();

                foreach (var endpoint in host.Description.Endpoints)
                {
                    Console.WriteLine("{0} ({1})",
                        endpoint.Address,
                        endpoint.Binding.Name);
                }

                Console.ReadLine();
            }
        }
开发者ID:shishkin,项目名称:dotnet-cologne-2010,代码行数:20,代码来源:Program.cs

示例7: Start

        public void Start()
        {
            Console.WriteLine("Starting local child process Service...");

            Uri baseAddress = DiscoveryUtils.DiscoveryHelper.AvailableTcpBaseAddress;

            this.FindCoordinator();

            _processHost = new ServiceHost(typeof(ChildProcess), baseAddress);

            _processHost.AddDefaultEndpoints();

            _processHost.Open();

            IntroduceToCoordinator();

            _worker = new Thread(new ThreadStart(DoWork));

            _worker.Start();

            StartStatusServer();
        }
开发者ID:Lewray,项目名称:DistributedSystem,代码行数:22,代码来源:ChildProcess.cs

示例8: StartElectionService

        private void StartElectionService()
        {
            Console.WriteLine("Starting local election service...");

            Uri baseAddress = DiscoveryHelper.AvailableTcpBaseAddress;

            _election = new Election();

            _election.Elected += ElectionElected;
            _election.ProcessLost += ElectionProcessLost;

            _election.FindConstituents();

            _electionHost = new ServiceHost(typeof(Election), baseAddress);

            _electionHost.AddDefaultEndpoints();

            _electionHost.Open();

            _election.ElectionIdentity = _electionHost.Description.Endpoints[1].Address;

            Console.WriteLine("Election Service Started at: {0}", _electionHost.Description.Endpoints[1].Address.ToString());
            Console.WriteLine();

            IntroduceElection();
        }
开发者ID:Lewray,项目名称:DistributedSystem,代码行数:26,代码来源:Process.cs

示例9: StartCoordinator

        private void StartCoordinator()
        {
            Console.WriteLine("Starting local Coordinator Service...");

            Uri baseAddress = DiscoveryUtils.DiscoveryHelper.AvailableTcpBaseAddress;

            this.FindProcesses();

            _coordinatorHost = new ServiceHost(typeof(Coordinator), baseAddress);

            _coordinatorHost.AddDefaultEndpoints();

            _coordinatorHost.Open();

            IntroduceToProcesses();
        }
开发者ID:Lewray,项目名称:DistributedSystem,代码行数:16,代码来源:Coordinator.cs

示例10: Main

        static void Main()
        {
            var realService = new ServiceHost(typeof (Service), new Uri("http://localhost:12345/a"));
            realService.AddDefaultEndpoints();
            var smb = new ServiceMetadataBehavior {HttpGetEnabled = true};
            realService.Description.Behaviors.Add(smb);
            realService.Open();

            var serviceHost = new ServiceHost(typeof (Duck), new Uri("http://localhost:12345/router"));
            serviceHost.AddDefaultEndpoints();
            serviceHost.Open();
            Console.WriteLine("Service is up and running.");

            var routerClient = ChannelFactory<IServiceClient>.CreateChannel(new BasicHttpBinding(),
                                                                         new EndpointAddress(
                                                                             "http://localhost:12345/router"));
            Console.WriteLine(routerClient.Op("bar"));

            Console.ReadLine();
            serviceHost.Close();
            realService.Close();
        }
开发者ID:miles-no,项目名称:SimpleWcfRouter,代码行数:22,代码来源:Program.cs


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