public void WebMessageFormats() { var host = new WebServiceHost(typeof(Hello)); host.AddServiceEndpoint(typeof(IHello), new WebHttpBinding(), "http://localhost:37564/"); host.Description.Behaviors.Find <ServiceDebugBehavior> ().IncludeExceptionDetailInFaults = true; host.Open(); try { // run client using (ChannelFactory <IHello> factory = new ChannelFactory <IHello> (new WebHttpBinding(), "http://localhost:37564/")) { factory.Endpoint.Behaviors.Add(new WebHttpBehavior()); IHello h = factory.CreateChannel(); //Console.WriteLine(h.SayHi("Joe", 42, null)); Assert.AreEqual("Hi Joe.", h.SayHi2(new User { Name = "Joe" }), "#1"); } } finally { host.Close(); } }