日期:2014-05-17 浏览次数:21011 次
NetTcpBinding myBinding = new NetTcpBinding();
myBinding.Security.Mode = SecurityMode.None;
myBinding.MaxReceivedMessageSize = 2147483647;
myBinding.TransferMode = TransferMode.Streamed;
myBinding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
myBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
myBinding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
Uri baseAddress = new Uri("net.tcp://" + ip + ":9999/WCFService/");
myServiceHost = new ServiceHost(typeof(Service), baseAddress);
ServiceEndpoint myServiceEndpoint = myServiceHost.AddServiceEndpoint
(typeof(IService), myBinding, "GetIdentity");
try
{
myServiceHost.Open();
if (myServiceHost.State == CommunicationState.Opened)
return true;
else
return false;
}
catch (Exception ex)
{
throw ex;
}
&n