Created
June 1, 2011 04:35
-
-
Save JayDouglass/1001794 to your computer and use it in GitHub Desktop.
WCF REST service host from console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.ServiceModel.Web; | |
using System.ServiceModel.Description; | |
namespace WCFRest.ConsoleServiceHost | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (var host = new ServiceHost(typeof(ServiceImpl), | |
new Uri(@"http://localhost:9000/ServiceAddress"))) | |
{ | |
host.AddServiceEndpoint(typeof(IServiceInterface), | |
new WebHttpBinding(WebHttpSecurityMode.None), | |
String.Empty) | |
.Behaviors.Add(new WebHttpBehavior()); | |
host.Open(); | |
System.Console.WriteLine("Press <ENTER> to terminate the service host"); | |
System.Console.ReadLine(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using WebServiceHost will take care of adding the WebHttpBehavior. WebServiceHostFactory should be used in .svc files.