- Timestamp:
- 01/19/16 12:45:18 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.ContactServer.Host/Program.cs
r13524 r13557 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 2 using System.ServiceModel; 5 using System.ServiceModel.Description;6 using System.Text;7 using System.Threading.Tasks;8 3 9 namespace DistributedGA.ContactServer.Host 10 { 11 class Program 12 { 13 static void Main(string[] args) 14 { 15 string baseAddress = string.Empty; 16 if(args.GetUpperBound(0) > -1) 17 { 18 baseAddress = args[0]; 19 } 20 if (string.IsNullOrWhiteSpace(baseAddress)) 21 { 22 baseAddress = "http://localhost:9090/DistributedGA.ContactServer/ContactService"; 23 } 24 using (ServiceHost host = new ServiceHost(typeof(ContactServiceImpl), new Uri[] { new Uri(baseAddress) })) 25 { 26 // Enable metadata publishing. 27 ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 28 smb.HttpGetEnabled = true; 29 smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; 30 host.Description.Behaviors.Add(smb); 4 namespace DistributedGA.ContactServer.Host { 5 class Program { 6 static void Main(string[] args) { 7 string baseAddress = string.Empty; 8 if (args.GetUpperBound(0) > -1) { 9 baseAddress = args[0]; 10 } 11 if (string.IsNullOrWhiteSpace(baseAddress)) { 12 baseAddress = "net.tcp://localhost:9090/DistributedGA.ContactServer/ContactService"; 13 } 14 using (ServiceHost host = new ServiceHost(typeof(ContactServiceImpl), new Uri[] { new Uri(baseAddress) })) { 15 // Enable metadata publishing. 31 16 32 // Open the ServiceHost to start listening for messages. Since33 // no endpoints are explicitly configured, the runtime will create34 // one endpoint per base address for each service contract implemented35 // by the service.36 37 host.Open();38 17 39 Console.WriteLine("The service is ready at {0}", baseAddress); 40 Console.WriteLine("Press <Enter> to stop the service."); 41 Console.ReadLine(); 18 // Open the ServiceHost to start listening for messages. Since 19 // no endpoints are explicitly configured, the runtime will create 20 // one endpoint per base address for each service contract implemented 21 // by the service. 42 22 43 // Close the ServiceHost. 44 host.Close(); 45 } 46 } 23 host.Open(); 24 25 Console.WriteLine("The service is ready at {0}", baseAddress); 26 Console.WriteLine("Press <Enter> to stop the service."); 27 Console.ReadLine(); 28 29 // Close the ServiceHost. 30 host.Close(); 31 } 47 32 } 33 } 48 34 }
Note: See TracChangeset
for help on using the changeset viewer.