如何建立WCF IP相关客户端

开发 后端
WCF IP其混合了函数语言和物件导向程序编制语言,并且完美的适用于编程、算法、技术和探索性开发,因此可以在使用的过程当中感受到趣味性和吸引力。

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

不说废话,直接看如何实现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.  
  20. return string.Format("Hello {0}! Your IP address is {1} and your port is {2}",  value, endpointProperty.Address, endpointProperty.Port);  
  21. }  
  22. }  
【编辑推荐】
  1. 解决相关WCF Service事件
  2. 详细介绍WCF回调返回值说明
  3. 更高效进行WCF代码编制介绍处理
  4. 如何正确对Silverlight WCF创建
  5. 对于WCF双向进行图示讲演
责任编辑:chenqingxiang 来源: NET130
相关推荐

2009-12-21 15:53:56

WCF获取客户端IP

2010-02-22 11:10:17

WCF获取客户端IP

2010-02-24 16:17:09

WCF获取客户端IP

2009-11-05 13:00:25

WCF客户端

2009-12-07 18:26:36

WCF客户端

2009-12-22 18:18:11

WCF客户端编程

2010-02-25 16:20:02

WCF客户端

2009-12-22 10:29:59

WCF客户端处理

2009-12-21 10:09:26

WCF创建客户端服务对

2019-10-29 05:34:34

IPJava服务器

2010-02-24 16:39:27

WCF客户端处理

2010-02-23 09:58:21

WCF客户端验证

2009-11-09 15:49:01

WCF异步调用

2009-11-05 13:08:44

WCF客户端配置

2011-09-09 09:44:23

WCF

2023-11-15 13:50:07

服务端IP

2018-12-19 10:31:32

客户端IP服务器

2009-12-21 10:19:05

Silverlight

2010-02-23 15:12:25

WCF客户端

2011-08-25 13:42:57

IP隧道IPIPGRE
点赞
收藏

51CTO技术栈公众号