Posted on 2010-05-05 23:59 Frank Xu Lei 阅读(13) 评论(0) 编辑 收藏 所属分类: SOA and EAI, WCF服务编程设计规范
今天继续《WCF服务编程设计规范》系列,今天推荐一下另外一个学习资料,并提供下载。作者是Brian Noyes,Juval Lowy 的同事。PPT资料《WCF Best Practice》,中文翻译为《WCF最佳实践》。今天内容主要包含,作者介绍,资料的目录结构,然后是翻译的前三部:服务定义、异常处理和安全。中英文对照。分享给大家。你可以下载英文版ppt。/Files/frank_xl/WCFBestPractices.pdf
【2】中文目录:
【3】英文名称:《WCF Best Practice》
中文名称:《WCF最佳实践》
【4】About Brian
关于Brian
l Brian Noyes
l Chief Architect, IDesign
IDesign 首席架构师
l brian.noyes@idesign.net
l Microsoft Regional Director
微软区域总监
l Microsoft MVP Connected Systems
微软MVP
l Publishing
出版
Ø Developing Applications with Windows Workflow Foundation,
Ø LiveLessons training DVD, June 2007
Ø Smart Client Deployment with ClickOnce, Addison Wesley,January 2007
Ø Data Binding in Windows Forms 2.0,
Ø Addison Wesley, January 2006
Ø MSDN Magazine, MSDN Online,
Ø CoDe Magazine, The Server Side .NET,
Ø asp.netPRO, Visual Studio Magazine
l Speaking
讲座
Ø Microsoft TechEd US, Europe, Malaysia,
Ø Visual Studio Connections, DevTeach,
Ø INETA Speakers Bureau, MSDN Webcasts
Ø E-mail: brian.noyes@idesign.net
Ø Blog: http://briannoyes.net
【5】Agenda
大纲
l Service Best Practices
服务最佳实践
l Client Best Practices
客户端最佳实践
l Data Contracts
数据契约最佳实践
l SOAP vs. REST
SOAP与Rest
【6】Service Definition
服务定义
l Separate contract from implementation
契约与实现分离
Ø Contract (interface) first
契约(接口)优先
l Define services in a class library, not directly in a Host project
在类库里定义服务,不要在宿主项目里定义
l Layering
分层
Ø Separate Service Layer?
划分服务层
l Instance model
实例模型
Ø Change to Per Call as default
设置Per Call(单调模式)为默认值
Ø Session / Singleton when?
何时使用会话/与单例模式?
【7】Service Exception Handling
服务异常处理
l For operation specific exceptions
为每个操作指定异常
Ø Try/catch, throw FaultException<T>
Try/catch,抛出FaultException<T>
l Favor using FaultException<T>
推荐使用FaultException<T>
Ø FaultException can be ambiguous to the client because unhandled exceptions arrive as a FaultException
FaultException对于客户端来说过于模糊,因为未处理的异常都会在客户端表现为FaultException。
l Include FaultContract in service contract definition if you throw FaultExceptions
如果你要跑出异常,请在服务契约定义里包含FaultContract(错误契约)
Ø Part of the API you are exposing
就要暴露的API的一部分
l For global exception handling from services
对于来此服务全局的异常处理
Ø Use an error handler
使用错误处理
l Include exception details in debug builds only
只有在调试的时候才会包含异常的详细信息
【8】Service Security
服务安全
l Intranet services
企业局域网(以太网)服务
Ø Default Windows Auth may be all you need
默认使用Windows验证
Ø Possibly Hybrid –Windows Creds / Custom Application Roles
或者使用Hybrid –Windows凭据/自定义Application角色
l Extranet / Internet / Custom security needs
企业外部网络/ Internet/自定义安全需求
l Use ASP.NET Membership / Role providers
使用ASP.NET Membership / Role providers
l ASP.NET providers
ASP.NET providers
Ø Really a standard .NET framework security infrastructure
一个标准的.NET framework安全基础结构
Ø Built in providers for Windows or SQL Server – based credentials / roles
在providers里为Windows或SQL Server内建了基于凭据/角色的安全机制
Ø Easy to implement custom providers
容易实现自定义providers
Ø Establish principal on the thread
线程上建立principal
Ø Re-usable across ASP.NET, WCF, WPF & Windows Forms (via Client Application Services)
Ø 可以跨越ASP.NET、WCF、WPF 与 Windows Forms (通过客户端应用程序服务)
【老徐的博客】
【作 者】:Frank Xu Lei
【地 址】:
【中文论坛】:微软WCF中文技术论坛
【英文论坛】:微软WCF英文技术论坛