|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProxyGeneration;
using System.ServiceModel;
using System.ServiceModel.Description;
namespace ProxyGenerationHost
{
class Program
{
static void Main(string[] args)
{
ServiceProc();
}
private static void ServiceProc()
{
ServiceHost host = new ServiceHost(typeof(ProxyServ));
try
{
Console.WriteLine("WCF Service: Starting Up");
host.Opened += new EventHandler(host_Opened);
host.Open();
Console.WriteLine("Please press any key to close...");
Console.ReadLine();
}
finally
{
if (host.State != System.ServiceModel.CommunicationState.Closed)
{
host.Close();
}
}
}
private static void host_Opened(object sender, EventArgs e)
{
Console.WriteLine("WCF Service: Running");
System.ServiceModel.ServiceHost host = (System.ServiceModel.ServiceHost)sender;
StringBuilder detailBuilder = new StringBuilder();
foreach (Uri baseAddress in host.BaseAddresses)
{
detailBuilder.AppendFormat("\r\nBase Address: {0}", baseAddress.ToString());
}
foreach (ServiceEndpoint endPoint in host.Description.Endpoints)
{
string address = endPoint.Address.ToString();
string bindingName = endPoint.Binding.Name;
detailBuilder.AppendFormat("\r\nEndpoint({0}): {1}", bindingName, address);
}
Console.WriteLine(detailBuilder.ToString());
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Chris is a full time software developer in London, UK.
He has a BSc in computer science and is busy taking courses in the MCTS stream.