首页 > Web开发 > 详细

WCF在tcp通道下启用httpget

时间:2015-02-10 10:53:28      阅读:181      评论:0      收藏:0      [点我收藏+]

关于tcp通道下,启用httpget,必须启用一个http的基地址,如果要启用无数据交换,host中必须开启服务描述。

            //01 create host
            Uri tcpBaseAddress = new Uri("net.tcp://127.0.0.1:12345/kp");
            Uri httpBaseAddress = new Uri("http://127.0.0.1:12346/kp");
            ServiceHost host = new ServiceHost(typeof(Po), tcpBaseAddress, httpBaseAddress);

            //02 add service metadata behavior
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            host.Description.Behaviors.Add(smb);

            //03 add endpoint
            host.AddServiceEndpoint(typeof(IPo), new NetTcpBinding(), "PoSvc");
            host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexTcpBinding(), "mex"); 
                
            host.Open();

            Console.ReadLine();

 

WCF在tcp通道下启用httpget

原文:http://www.cnblogs.com/shi5588/p/4283244.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!