wcf客户端(测试服务端)
这是为自己配置的一套集合测试用的, 里面有oracl、sql server的连接文件类,发送邮件类、 DES加密/解密类,信息截取过滤类、类型转换类、保存日志到文件中功能等 static void Main(string[] args) { PublicQuery qs = new PublicQuery(); Type service1 = typeof(WCFServices); using (ServiceHost host = new ServiceHost(service1)) { Console.WriteLine(); Console.WriteLine("后台WCF服务器 开始运行...."); Console.WriteLine(); string hostAddress = host.BaseAddresses[0].ToString(); Console.WriteLine("服务地址: " + hostAddress + "\r\n"); string temp = hostAddress.Substring(hostAddress.LastIndexOf(":") + 1); string hostPort = temp.Substring(0, temp.IndexOf("/")); //抬头修改 Console.Title = "系统启动,端口:" + hostPort; Console.WriteLine(); host.Open(); Console.WriteLine("按 ESC 即可开始结束程序运行!"); string strIsYes = ""; do { string strExit = Console.ReadLine(); while (strExit.ToLower() != "esc") { System.Threading.Thread.Sleep(1000); Console.WriteLine("按 ESC 即可开始结束程序运行!"); strExit = ""; strExit = Console.ReadLine(); } // Console.Write("确实退出 ? (y/n) "); strIsYes = Console.ReadLine(); } while (strIsYes.ToLower() != "y"); //关闭服务连接 if (host.State == CommunicationState.Opened) { host.Close(); System.Threading.Thread.Sleep(1000); } ---------------------------- app.config <endpoint address="WCFServices" bindingConfiguration="BasicHttpBinding_IWCFServices" binding="basicHttpBinding" contract="RuralService.IWCFServices" /> <host> <baseAddresses> <add baseAddress="http://127.0.0.1:8088/WCFServices/" /> </baseAddresses> </host>
- 1
- 粉丝: 0
- 资源: 10
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助