我学WCF之旅(二)
来源:互联网 发布:西安广电网络大酒店 编辑:程序博客网 时间:2024/05/22 03:56
原文:Endpoint Overview
我在学习这一章节的时候着重验证了下通信时Endpoint的Address和Binding必须匹配才能够通信。
我没有原作者提供的Sample,而是用了上次的Solution.
修改如下:
1.在Hosting 项目里加了Address,变成
Uri httpBaseAddress = new Uri(http://localhost:8888/generalCalculator);
Uri tcpBaseAddress = new Uri("net.tcp://localhost:9999/generalCalculator");
当然了不同的地址需要的Binding 也不一样: BasicHttpBinding httpbinding = new BasicHttpBinding(); NetTcpBinding tcpbinging = new NetTcpBinding(); host.AddServiceEndpoint( host.AddServiceEndpoint(
保存->Build->OPen Folder in Windows Explorer -> using Administrator to run Hosting.exe in bin/debug.
2.Client项目
我们已经在代码中更新了Service,这里也需要更新你的Service Reference 里的Service.
因为得我端口该了,所以我直接删了原来的Service Reference ,新添加了一个。但是在我新加的时候
在Add Service Reference dialog里的Address栏里,我试了一下几种
(1) http://localhost:8888/generalCalculator 能找到,可以添加
(2) net.tcp://localhost:9999/generalCalculator 不能找到
(3) http://localhost:8887/generalCalculator 不能找到
(4) http://localhost/generalCalculator 不能找到
(5) http://localhost 不能找到
里面应该有什么规则,还不知道,后续..
我可以通过方案1找到我的Service,就在Client里写了2种Code 来Invoke 这个Service。
需要注意的地方:Binding 和Address要匹配
string.Empty*这里的含义,The address for the endpoint added. This can be an absolute or relative URI. If it is a relative URI, one of the base address of the ServiceHost (depending on the binding protocol) is used as the endpoint's base address.来自MSDN
- 我学WCF之旅(二)
- 我学WCF之旅(一)
- 我的WCF之旅
- 我的WCF之旅
- 我的WCF之旅
- 我的WCF学习之旅(1)什么是WCF
- WCF探索之旅(二)——从零开始WCF实例
- 我学MSMQ(二)
- 我学MSMQ(二)
- WCF教程二之WCF架构
- 跟我学aspectj之二 ----- 搭建开发环境
- 跟我学REDIS-REDIS(二)----常用数据类型之string
- 跟我学REDIS-REDIS(二)----常用数据类型之Lists
- 跟我学Android之二 第一个程序
- 跟我学框架之struts框架搭建(二)
- 与我一起学C++之list<二>
- "我的WCF之旅"系列阶段性总结
- [原创]我的WCF之旅(2):Endpoint Overview
- oracle 如何把数据库变为非归档日志模式
- jQuery 常见操作实现方式
- sql server 2005只备份数据库的结构
- 利用 CSS Friendly Control Adapters 将 ASP.NET 控件转为符合WEB标准标签控制
- 常用排序算法
- 我学WCF之旅(二)
- GDB的使用方法(转)
- JAVA 代理模式
- 进入社会-慢慢有点感觉了
- STL里的数据结构
- Struts2搭建
- 物联网应用之 - 基于位置的车载网络信息服务Aha
- DELPHI参数几个概念上的区别
- 动态表格js兼容(ie.ff)