// It is almost identical to samples/basic-http-binding public void SimpleHttpConnection() { // Service ServiceHost host = new ServiceHost(typeof(Foo)); int port = NetworkHelpers.FindFreePort(); try { Binding binding = new BasicHttpBinding(); binding.SendTimeout = binding.ReceiveTimeout = TimeSpan.FromSeconds(5); ServiceEndpoint se = host.AddServiceEndpoint("MonoTests.System.ServiceModel.IFoo", binding, new Uri("http://localhost:" + port)); host.Open(); // Client ChannelFactory <IFoo> cf = new ChannelFactory <IFoo> ( new BasicHttpBinding(), new EndpointAddress("http://localhost:" + port + "/")); IFoo foo = cf.CreateChannel(); Assert.AreEqual("Test for EchoTest for Echo", foo.Echo("Test for Echo")); } finally { if (host.State == CommunicationState.Opened) { host.Close(); } } }