• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > 编程与数据库 > net编程 >

WCF服务编程设计规范(2):序言、通用设计规范和要点(3)

来源: www.dedecms8.com 编辑:织梦吧 时间:2012-06-27点击:

[ServiceContract(Namespace = "MyApplication")]

interface IMyContract

{...}

5.With intranet applications on prefer self-hosting to IIS hosting when the WAS is unavailable.

对于企业内部应用系统,当WAS不可用的时候,推荐自托管self-hosting而不是IIS。

6.Do not mix and match named bindings with default bindings.Either have all your bindings be explicitly referenced, or use only default bindings.

不要混用指定绑定和默认绑定。要么全部明确指定绑定,要么只使用默认绑定。

7.Do not mix and match named behaviors with default behaviors.Either have all your behaviors be explicitly referenced, or use only default behaviors.

不要混用指定行为和默认行为,要么全部明确执行行为,要么使用默认行为。

8.Always name all endpoints in the client config file.

在客户端的配置文件里,定义终结点的名字name.

9.Do not use SvcUtil or Visual Studio 2010 to generate a config file.

不要使用SvcUtil工具或者Visual Studio 2010去生成配置文件。(这里工具会使用很多默认的设置,这些会带来潜在的问题,在产品部署以后,比如TimeOut和MessageMaxSize等,最好自己能手动更改这些配置)

10.When using a tool such as Visual Studio 2010 to generate the proxy, do clean up the proxy.

当使用Visual Studio 2010生成客户端代理的时候,记得释放代理。(这里应该是重写IDispose的Dispose方法,释放非托管资源。Proxy默认是继)

11.Do not duplicate proxy code.If two or more clients use the same contract, factor the  proxy to a separate class library.

不要复制代理代码。如果两个或多个客户端使用了相同的契约,把代理分解到独立的类库里。(这里不建议复制Proxy代码的方式。如果你有多个客户端,比如A 是一个Console程序,B是一个WindowsService程序,C是一个WinForm程序,都调用了相同的WCF服务,可以把这个WCF客户端放在一个类库里DLL,其它项目都引用即可)

12.Always close or dispose of the proxy.

通常要关闭或者销毁(close或dispose proxy)代理实例。(客户端代理包含网络连接等珍贵资源,继续释放,调用Close方法或者在Using体力声明客户端代理即可)

13.When using discovery, prefer dynamic addresses.

当使用服务发现机制的时候,推荐动态地址。(动态定位服务地址是WCF服务发现的优势)

14.When using discovery, do support the metadata exchange endpoint over TCP.

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1170734538@qq.com ,  QQ