If WCF Service side and Client side config is different?!
from stackoverflow
最近配置wcf服务,一直有个疑问,一直我们配置wcf服务端跟client端总是一致的,但是如果我们配置的不一样呢?在stackoverflow找到以下答案。其实这个没有说一定那边起作用,比如client的sendtimeout对应的是service端的receivetimeout,而且在client端有些配置是没有用的。这个还得细细琢磨。我擦。。。
In order to address your request in your last comment to my previous answer, I tried to come up with my approach to how I would create (and modify) server- and client-side config's for any given service. This is based on both theory I read (books, blogs), things I've learned in Juval Lowy's WCF Master Class, and quite a bit of practical experience with several large service implementation projects - this isn't available in one single place, on the web or in a book.... so here it goes:
I would start basically from scratch. Think about your service first:
- what address does your service live at?
- what binding(s) do you want to support?
Simplest scenario: single service, single endpoint, basicHttpBinding, all defaults
Service config:
<system.serviceModel>
<services>
<service name="YourNamespace.YourServiceClass">
<endpoint name="Default"
address="http://YourServer/SomeVirtualDirectory/YourService.svc"
binding="basicHttpBinding"
contract="YourNamespace.IYourServiceContract" />
</service>
</services>
</system.serviceModel>
Corresponding client config:
<system.serviceModel>
<client name="Default">
<endpoint name="Default"
address="http://YourServer/SomeVirtualDirectory/YourService.svc"
binding="basicHttpBinding"
contract="YourClientProxyNamespace.IYourServiceContract" />
</client>
</system.serviceModel>
Then only ever change something if you really must! And most of all: NEVER EVER let Visual Studio (Add Service Reference) or svcutil.exe screw up your config! Protect it like the apple of your eye!
Then: if e.g. your data transfer takes more time than the default timeout of 1 minute allows, change that one single setting on both the service side and the client side. Do this by defining a custom binding configuration and referencing that from your endpoints - but change only that - not more!Leave everything else as is, with default values. Don't ever change anything unless you absolutely must (and know what you're doing, and why you're doing it).
Mind you: the sendTimeout on the client (time allowed until the whole message has been sent) will correspond to the receiveTimeout on the server - the time allowed for the whole message to come in (see this excellent blog post and this MSDN forum thread for more information)
Service config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ExtendedTimeout"
receiveTimeout="00:05:00" />
</basicHttpBinding>
</bindings>
<services>
<service name="YourNamespace.YourServiceClass">
<endpoint name="Default"
address="http://YourServer/SomeVirtualDirectory/YourService.svc"
binding="basicHttpBinding"
bindingConfiguration="ExtendedTimeout"
contract="YourNamespace.IYourServiceContract" />
</service>
</services>
</system.serviceModel>
Corresponding client config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ExtendedTimeout"
sendTimeout="00:05:00" />
</basicHttpBinding>
</bindings>
<client name="Default">
<endpoint name="Default"
address="http://YourServer/SomeVirtualDirectory/YourService.svc"
binding="basicHttpBinding"
bindingConfiguration="ExtendedTimeout"
contract="YourClientProxyNamespace.IYourServiceContract" />
</client>
</system.serviceModel>
As you need other changes, like multiple endpoints on the service side, or local settings like bypassProxyOnLocal - adapt your config, do it carefully, step by step, manually, and consider your config an extremely essential part of your whole service - take care of it, put it in version control etc.
If WCF Service side and Client side config is different?!的更多相关文章
- 这样修改有哪些优缺点 wcf service via attribute setting vs config
客户要恢复数据,结果就是block在某个阶段,在server端log一圈下来,发现原来是client端出了问题,就是这个log: ERROR - Identity check failed for o ...
- 如何创建一个RESTful WCF Service
原创地址:http://www.cnblogs.com/jfzhu/p/4044813.html 转载请注明出处 (一)web.config文件 要创建REST WCF Service,endpoin ...
- [转]Consuming a OData Service in a Client Application (WCF Data Services)
本文转自:https://msdn.microsoft.com/zh-tw/library/dd728282(v=vs.103).aspx WCF Data Services 5.0 其他版本 ...
- 如何创建一个AJAX-Enabled WCF Service
原创地址:http://www.cnblogs.com/jfzhu/p/4041638.html 转载请注明出处 前面的文章中介绍过<Step by Step 创建一个WCF Servi ...
- 用JavaScript调用WCF Service
原创地址:http://www.cnblogs.com/jfzhu/p/4039604.html 转载请注明出处 前面介绍过<Step by Step 创建一个WCF Service>和& ...
- Step by Step 创建一个WCF Service
原创地址:http://www.cnblogs.com/jfzhu/p/4025448.html 转载请注明出处 (一)创建WCF Service (1)创建WCF Service类库 创建一个Cla ...
- 十五天精通WCF——第二天 告别烦恼的config配置
经常搞wcf的基友们肯定会知道,当你的应用程序有很多的“服务引用”的时候,是不是有一种疯狂的感觉...从一个环境迁移到另外一个环境,你需要改变的 endpoint会超级tmd的多,简直就是搞死了人.. ...
- WCF - Consuming WCF Service
WCF services allow other applications to access or consume them. A WCF service can be consumed by ma ...
- WCF Service端Inspector
问题 在使用WCF的过程中,有时候需要在service端截取client和service之间的消息来做一些如写log,检查message是否合法的操作. 那么如何才能实现呢? 解决方案 使用WCF提供 ...
随机推荐
- 冲刺阶段 day13
---恢复内容开始--- 项目进展 今天星期三,我们将专业管理部分又继续做了完善,之前漏掉的几项功也一一补全,没能实现的数据库部分也已经进行了完善,并且对已经完成的部分进行了检测,数据库的部分还有待进 ...
- js中的console很强大
今天闲来没事,瞎逛, 发现了淘宝首页的这个: 想起来之前在百度的 页面中也曾看到过.于是乎自己试一试. 于是便见识到了console对象其实很强大,用好它对调试真的有很大帮助. 代码: <!DO ...
- php 润年 星期 天数
详细: 闰年.星期.天 echo date(|-|L|-|); 今年是否闰年: echo date(|-|l|-|); 今天是:Tuesday echo date(|-|D|-|); 今天是:Tue ...
- [nRF51822] 4、 图解nRF51 SDK中的Schedule handling library 和Timer library
:nRF51822虽然是一个小型的单片机,但是能真正达到任意调用其官方驱动以及BLE协议栈的人还是奇缺的.据我所见,大都拿官方给的一个冗长的蓝牙低功耗心率计工程改的.之前我对于这个工程进行log跟踪, ...
- mysqlnd cannot connect to MySQL 4.1+
phpMyAdmin - error #2000 - mysqlnd cannot connect to MySQL 4.1+ using the old insecure authenticatio ...
- jquery获取checkbox的值并post提交
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- EF架构~CodeFirst模型下的数据初始化
回到目录 我为什么会来 在传统的大型系统设计中,数据库建模是个比开发更早的环节,先有数据库,然后是ORM模型,最后才是开发程序,而这种模型在EF出现后发生了转变,而且有可能将来会被code first ...
- Atitit 图像处理之理解卷积attilax总结
Atitit 图像处理之理解卷积attilax总结 卷积的运算可以分为反转.平移,相乘,求和. 在图像处理中,图像是一个大矩阵,卷积模板是一个小矩阵.按照上述过程,就是先把小矩阵反转,然 ...
- maven install 读取jar包时出错;error in opening zip file
错误信息: [INFO] ------------------------------------------------------------------------ [ERROR] Failed ...
- 每天一个linux命令(39):grep 命令
Linux系统中grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹 配的行打印出来.grep全称是Global Regular Expression Print,表示全局正则表达 ...