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提供 ...
随机推荐
- C#实现 word、pdf、ppt 转为图片
office word文档.pdf文档.powerpoint幻灯片是非常常用的文档类型,在现实中经常有需求需要将它们转换成图片 -- 即将word.pdf.ppt文档的每一页转换成一张对应的图片,就像 ...
- Wix 安装部署教程(十一) ---QuickWix
这次发布的是这两天做的一个WIX工具QuickWIX,主要解决两个问题点1.对大文件快速生成wix标签(files,Directories,ComponentRef):2.比较前后两次工程的差异.大的 ...
- 《CLR.via.C#第三版》第二部分第4,5章节读书笔记(二)
这两章全是理论性的东西,我觉得不必过于钻牛角尖.理论这东西,只有在长期的实践中去慢慢领悟才会深刻.下面我只写些我认为重要的关键知识. (一)类型转换 知识点:向基类型的转换被认为是一种安全的隐式转换: ...
- ubuntu 13.04下MYSQL 5.5环境搭建
解决的问题: 安装mysql server和mysql client 5.5 新建远程账户 远程访问权限 MYSQL默认字符集修改为UTF8 检查防火墙 一.安装 BTW:可以使用查找命令查看安装包 ...
- 分离EF connectionString里的db连接串
创建EF模型后,自动生成的connectionString如下: <add name="TravelPPEntities" connectionString="me ...
- h5原生拖拽
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Atitit usrQBK13 html dsl 规范与解决方案
Atitit usrQBK13 html dsl 规范与解决方案 1.1. Vue vs anrular1 1.2. 定义html dsl变量1 1.3. 变量赋值1 1.4. 条件渲染指令1 2 ...
- Servlet字符编码过滤器,实现图书信息的添加功能,避免产生文字乱码现象的产生
同样的代码,网上可以找到和我一模一样的代码和配置,比我的更加详细,但是我重新写一个博客的原因自是把错误的原因写出来,因为这就是个坑,我弄了一天,希望对你们有所帮助.只为初学者发现错误不知道怎么解决有所 ...
- CCNA学习 NAT网络地址转换
CCNA基础 NAT网络地址转换 在计算机网络中,网络地址转换(Network Address Translation,缩写为NAT),也叫做网络掩蔽或者IP掩蔽(IP masquerading),是 ...
- SSH无密码登录
首先生成密钥对 ssh-keygen -t rsa cd ~/.ssh/ cat id_rsa.pub 复制你生成的公钥 登录到需要免登录的服务器 cd ~/.ssh 添加到 authorized_k ...