RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
如何建立WCFIP相关客户端

我在家里使用WCF做通讯,里面需要WCF做客户端的IP,经过在服务器上进行了修改,我却发现WCF 3.0 里面并不支持这个功能。没事上周在微软官网下的3.5的新版WCF中提供了WCF IP这个方法。

创新互联为企业级客户提高一站式互联网+设计服务,主要包括网站制作、成都网站建设app开发定制微信小程序开发、宣传片制作、LOGO设计等,帮助客户快速提升营销能力和企业形象,创新互联各部门都有经验丰富的经验,可以确保每一个作品的质量和创作周期,同时每年都有很多新员工加入,为我们带来大量新的创意。 

不说废话,直接看如何实现WCF IP。简单定义一个WCF IP服务:

  
  
  
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.Serialization;
  5. using System.ServiceModel;
  6. using System.Text;
  7. using System.ServiceModel.Channels; 
  8. namespace ClientInfoSample
  9. {
  10. public class MyService : IService
  11. {
  12. public string GetData(string value)
  13. {
  14. OperationContext context = OperationContext.Current;
  15. MessageProperties essageProperties = context.IncomingMessageProperties;
  16. RemoteEndpointMessageProperty endpointProperty =
  17. messageProperties  [RemoteEndpointMessageProperty.Name]
  18. as RemoteEndpointMessageProperty;
  19. return string.Format("Hello {0}! Your IP address is {1} and your port is {2}",  value, endpointProperty.Address, endpointProperty.Port);
  20. }
  21. }
  22. }

当前文章:如何建立WCFIP相关客户端
网页网址:http://www.jxjierui.cn/article/dpjssoi.html