public void RemoteEndpointMessageProperty() { IWebHost host = ServiceHelper.CreateWebHostBuilder <Startup>(_output).Build(); using (host) { host.Start(); System.ServiceModel.NetTcpBinding nettcpBinding = ClientHelper.GetBufferedModeBinding(); var factory = new System.ServiceModel.ChannelFactory <ClientContract.IRemoteEndpointMessageProperty>(nettcpBinding, new System.ServiceModel.EndpointAddress(new Uri(host.GetNetTcpAddressInUse() + "/RemoteEndpointMessagePropertyService.svc"))); ClientContract.IRemoteEndpointMessageProperty channel = factory.CreateChannel(); Message request = Message.CreateMessage(nettcpBinding.MessageVersion, "echo", "PASS"); Message response = channel.Echo(request); string[] results = response.GetBody <string>().Split(';'); Assert.Equal(3, results.Length); Assert.Equal("PASS", results[0]); string clientIP = results[1]; CheckIP(clientIP); NetstatResults(results[2], host.GetNetTcpPortInUse().ToString()); } }
public static string GetNetTcpAddressInUse(this IWebHost host) { return($"net.tcp://localhost:{host.GetNetTcpPortInUse()}"); }