from stackoverflow

http://stackoverflow.com/questions/4879310/when-setting-up-a-wcf-client-and-server-how-synchronized-does-the-config-files

最近配置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?!的更多相关文章

  1. 这样修改有哪些优缺点 wcf service via attribute setting vs config

    客户要恢复数据,结果就是block在某个阶段,在server端log一圈下来,发现原来是client端出了问题,就是这个log: ERROR - Identity check failed for o ...

  2. 如何创建一个RESTful WCF Service

    原创地址:http://www.cnblogs.com/jfzhu/p/4044813.html 转载请注明出处 (一)web.config文件 要创建REST WCF Service,endpoin ...

  3. [转]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   其他版本   ...

  4. 如何创建一个AJAX-Enabled WCF Service

      原创地址:http://www.cnblogs.com/jfzhu/p/4041638.html 转载请注明出处   前面的文章中介绍过<Step by Step 创建一个WCF Servi ...

  5. 用JavaScript调用WCF Service

    原创地址:http://www.cnblogs.com/jfzhu/p/4039604.html 转载请注明出处 前面介绍过<Step by Step 创建一个WCF Service>和& ...

  6. Step by Step 创建一个WCF Service

    原创地址:http://www.cnblogs.com/jfzhu/p/4025448.html 转载请注明出处 (一)创建WCF Service (1)创建WCF Service类库 创建一个Cla ...

  7. 十五天精通WCF——第二天 告别烦恼的config配置

    经常搞wcf的基友们肯定会知道,当你的应用程序有很多的“服务引用”的时候,是不是有一种疯狂的感觉...从一个环境迁移到另外一个环境,你需要改变的 endpoint会超级tmd的多,简直就是搞死了人.. ...

  8. WCF - Consuming WCF Service

    WCF services allow other applications to access or consume them. A WCF service can be consumed by ma ...

  9. WCF Service端Inspector

    问题 在使用WCF的过程中,有时候需要在service端截取client和service之间的消息来做一些如写log,检查message是否合法的操作. 那么如何才能实现呢? 解决方案 使用WCF提供 ...

随机推荐

  1. Linux下安装Apache并以mod_wsgi方式部署django站点

    源码编译方式安装Apache 首先下载Apache源码压缩包,地址为http://mirror.bit.edu.cn/apache/httpd/ 继续下载apr和apr-util压缩包,地址为http ...

  2. ECMAScript5 Array新增方法

    数组在各个编程语言中的重要性不言而喻,但是在之前的JavaScript中数组(JavaScript 数组详解)虽然功能已经很强大,但操作方法并不完善,在ECMAScript5中做了适当的补充. Arr ...

  3. 简化工作流程,10款必备的HTML5开发工具

    利用HTML5工具不仅可以帮助设计师和开发者创建更具吸引力的网站,还能增加网站的可用性和可访问性.本文收集了10款HTML5开发工具让你在网页中搭建特效.动画.视频.音频等诸多功能,为你节省更多开发时 ...

  4. UStore-自定义JDF文件格式输出

    系统默认的JDF输出不能满足我们的需求,往往不同的供应商输出不同要求的JDF格式.这里我们开始介绍ustore的自定义JDF输出 1.先屏蔽掉默认的JDF格式输出 我们进入Tigger来设置ustro ...

  5. UStore-添加自定义工作流(JDF)到产品

    这里使用的是8.2版本.所有的帮助文档可以在可以看到: http://www.xmpie.com/uStore%20Help/uStore_Help_Page.htm 1.登录 首先,登录到ustor ...

  6. Atitit attilax在自然语言处理领域的成果

    Atitit attilax在自然语言处理领域的成果 1.1. 完整的自然语言架构方案(词汇,语法,文字的选型与搭配)1 1.2. 中文分词1 1.3. 全文检索1 1.4. 中文 阿拉伯文 英文的简 ...

  7. SQL Server 2012 数据库笔记

    慕课网 首页 实战 路径 猿问 手记     Python 手记 \ SQL Server 2012 数据库笔记 SQL Server 2012 数据库笔记 2016-10-25 16:29:33 1 ...

  8. MySql数据库乱码解决方法

    MySql数据库乱码解决方法 解决乱码问题一个原则:存取系统使用一致的编码规则. 多使用mysql的原生命令行,这样才能做更多的事情. ​ 第一步: 确认应用系统需要使用的编码 java的默认编码是跟 ...

  9. android 股票数据通过日K获取周K的数据 算法 源码

    目前的数据是从新浪接口获取的, http://biz.finance.sina.com.cn/stock/flash_hq/kline_data.php?symbol=sh600000&end ...

  10. Nodejs从有门道无门菜鸟起飞教程。

    这是一篇菜鸟教程,这是一篇菜鸟教程,如果你是菜鸟到话. 简单来说Nodejs并不是一门新的语言,但是它可以让我们的JS运行在服务器端,在服务器端写JS代码并且输入输出,也就是说以后要是有人问你JS是不 ...