TcpTrace路由解析,参考页面-http://www.cnblogs.com/artech/archive/2008/09/19/1294227.html

TcpTrace工具下载地址:http://www.piaodown.com/soft/43538.htm

原理:模拟路由的方式进行客户端的消息转发,回复。如图:

代码结构如下:

分别为ICalculator:

using System.Linq;
using System.Text;
using System.ServiceModel; namespace Artech.TcpTraceDemo.Contracts
{
[ServiceContract(Namespace = "http://www.artech.com/")]
public interface ICalculator
{
[OperationContract]
double Add(double x, double y);
}
}

Service:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Artech.TcpTraceDemo.Contracts; namespace Artech.TcpTraceDemo.Services
{
public class CalculatorService:ICalculator
{ public double Add(double x, double y)
{
return x + y;
}
}
}

Hosting

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Artech.TcpTraceDemo.Services; namespace Artech.TcpTraceDemo.Hosting
{
class Program
{
static void Main(string[] args)
{
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService)))
{
serviceHost.Open();
Console.Read();
}
}
}
}

Hosting,Appconfig

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel> <bindings>
<customBinding>
<binding name="SimpleBinding">
<textMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="Artech.TcpTraceDemo.Services.CalculatorService">
<endpoint address="http://127.0.0.1:9999/CalculatorService" binding="customBinding"
bindingConfiguration="SimpleBinding" contract="Artech.TcpTraceDemo.Contracts.ICalculator" listenUri="http://127.0.0.1:8888/CalculatorService"></endpoint>
</service> </services> </system.serviceModel>
</configuration>

Clients:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Artech.TcpTraceDemo.Contracts;
using System.ServiceModel; namespace Artech.TcpTraceDemo.Clients
{
class Program
{
static void Main(string[] args)
{
using (ChannelFactory<ICalculator> ChannelFactory = new ChannelFactory<ICalculator>("CalculatorService"))
{
ICalculator calculator = ChannelFactory.CreateChannel();
using (calculator as IDisposable)
{
Console.WriteLine("x+y={2} where x={0} and y={1}", , , calculator.Add(,)); }
} Console.ReadLine();
}
}
}

Clients,Appconfig

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="SimpleBinding">
<textMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://127.0.0.1:9999/CalculatorService" binding="customBinding"
bindingConfiguration="SimpleBinding" contract="Artech.TcpTraceDemo.Contracts.ICalculator"
name="CalculatorService"></endpoint>
</client>
</system.serviceModel>
</configuration>

WCF技术解剖2-TcpTracer路由解析代码的更多相关文章

  1. 【朝夕技术专刊】RabbitMQ路由解析(上篇)

    欢迎大家阅读<朝夕Net社区技术专刊> 我们致力于.NetCore的推广和落地,为更好的帮助大家学习,方便分享干货,特创此刊!很高兴你能成为忠实读者,文末福利不要错过哦! 上篇文章介绍了如 ...

  2. bottle.py中的路由解析代码

    # Routing def compile_route(route): """ Compiles a route string and returns a precomp ...

  3. ASP.NET Web API路由解析

    前言 本篇文章比较长,仔细思考阅读下来大约需要15分钟,涉及类图有可能在手机显示不完整,可以切换电脑版阅读. 做.Net有好几年时间了从ASP.NET WebForm到ASP.NET MVC再到ASP ...

  4. WCF技术剖析之三十:一个很有用的WCF调用编程技巧[下篇]

    原文:WCF技术剖析之三十:一个很有用的WCF调用编程技巧[下篇] 在<上篇>中,我通过使用Delegate的方式解决了服务调用过程中的异常处理以及对服务代理的关闭.对于<WCF技术 ...

  5. WCF技术剖析之二十二: 深入剖析WCF底层异常处理框架实现原理[中篇]

    原文:WCF技术剖析之二十二: 深入剖析WCF底层异常处理框架实现原理[中篇] 在[上篇]中,我们分别站在消息交换和编程的角度介绍了SOAP Fault和FaultException异常.在服务执行过 ...

  6. WCF技术剖析之四:基于IIS的WCF服务寄宿(Hosting)实现揭秘

    原文:WCF技术剖析之四:基于IIS的WCF服务寄宿(Hosting)实现揭秘 通过<再谈IIS与ASP.NET管道>的介绍,相信读者已经对IIS和ASP.NET的请求处理管道有了一个大致 ...

  7. WCF技术剖析之一:通过一个ASP.NET程序模拟WCF基础架构

    原文:WCF技术剖析之一:通过一个ASP.NET程序模拟WCF基础架构 细算起来,已经有好几个月没有真正的写过文章了.近半年以来,一直忙于我的第一本WCF专著<WCF技术剖析>的写作,一直 ...

  8. 《WCF技术剖析》博文系列汇总[持续更新中]

    原文:<WCF技术剖析>博文系列汇总[持续更新中] 近半年以来,一直忙于我的第一本WCF专著<WCF技术剖析(卷1)>的写作,一直无暇管理自己的Blog.在<WCF技术剖 ...

  9. 利用WCF技术降低系统之间的耦合度

    为了降低本系统各个组件之间的耦合度,本系统将BLL层采用WCF技术发布为Web Service,以供UI层调用. 前面我们已经介绍过,为什么UI层不直接调用BLL层,而是要经过UI->Servi ...

随机推荐

  1. 【转载】谈MongoDB的应用场景

    引用:http://blog.csdn.net/adparking/article/details/38727911 MongoDB的应用场景在网上搜索了下,很少介绍关于传统的信息化应用中如何使用Mo ...

  2. 9.5web service基础知识

    Web服务基础 用户访问网站的基本流程 我们每天都会用web客户端上网,浏览器就是一个web客户端,例如谷歌浏览器,以及火狐浏览器等. 当我们输入www.oldboyedu.com/时候,很快就能看到 ...

  3. JSONP解决跨域完整例子

    1.这个案例是仿照百度搜索,输入关键词,会出现下拉菜单的过程. 效果: 2.具体做法: (1)利用百度的数据库做script标签的src. 复制之后的地址是这样的 https://sp0.baidu. ...

  4. MyEclipse - 问题集 - maven update project 后,项目jdk的版本变化

    解决方法: 进入maven安装根目录,conf/settings.xml <profiles> <profile> <id>jdk-1.7</id> & ...

  5. C语言库函数实现 【微软面试100题 第八十三题】

    题目要求 1.strcpy/memcpy/memmove: 2.memset函数: 3.字符串处理函数. 题目分析 1.接口定义: char * strcpy(char * dest, const c ...

  6. Android保持屏幕常亮唤醒状态

    第一步:  首先添加权限: <uses-permission android:name="android.permission.WAKE_LOCK"></uses ...

  7. 什么情况使用 weak 关键字,相比 assign 有什么不同?

    什么情况使用 weak 关键字? 在 ARC 中,在有可能出现循环引用的时候,往往要通过让其中一端使用 weak 来解决,比如: delegate 代理属性 自身已经对它进行一次强引用,没有必要再强引 ...

  8. HUAWEI TAG-AL00 找IMEI的过程

    前几天,遇到一台华为机型,IMEI获取有问题,然后就找了一下. 以下是解决过程,权当记录一下,尽管为知笔记已经有备份了 :) 0x01: 起因 测试小哥发现,一台机型IMEI获取不全,有问题,拨号页面 ...

  9. 转载——一步步学习js

    一步步学习javascript基础篇(0):开篇索引 阅读目录 索引: 一步步学习javascript基础篇(1):基本概念 一步步学习javascript基础篇(2):作用域和作用域链 一步步学习j ...

  10. 每天一个Linux命令(10):mv命令

    mv命令用来对文件或目录重新命名,或者将文件从一个目录移到另一个目录中.source表示源文件或目录,target表示目标文件或目录.如果将一个文件移到一个已经存在的目标文件中,则目标文件的内容将被覆 ...