频 道 直 达 - 新闻 - 读书 - 培训 - 教程 - 前沿 - 组网 - 系统应用 - 安全 - 编程 - 存储 - 操作系统 - 数据库 - 服务器 - 专题 - 产品 - 案例库 - 技术圈 - 博客 - BBS
51CTO.COM_中国领先的IT技术网站
找资料:

WCF体验之旅(7):SOA和OOP的结合—如何实现Service Contract的继承(7)

作者: Artech 出处:博客园 2008-03-14 11:36    砖    好    评论   进入论坛
阅读提示:当今的IT领域,SOA已经成为了一个非常时髦的词,对SOA风靡的程度已经让很多人对SOA,对面向服务产生误解。其中很大一部分人甚至认为面向服务将是面向对象的终结,现在的面向对象将会被面向服务完全代替。

IFullWhetherForecast.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using Artech.InheritanceHierarchy.BusinessEntity;

namespace Artech.InheritanceHierarchy. Client
{
[ServiceContract]
public interface IFullWhetherForecast:ISimpleWhetherForecast
{
[OperationContract]
WindInfo GetWindInfo(string postalcode);
}
}


除了namespace,和Service端的contract没有什么区别。

Step2:引用Artech.InheritanceHierarchy.BusinessEntity

Step3:配置Endpoint

http://localhost/Artech.InheritanceHierarchy/FullWhetherForecastService.svc"
binding="wsHttpBinding" bindingConfiguration=""  contract="Artech.

InheritanceHierarchy.Client.IFullWhetherForecast"/>

因为Service端的Endpoint对应的Contract是Artech.InheritanceHierarchy.Service IFullWhetherForecast,所以我们适应对应的Client端的Contract:Artech.InheritanceHierarchy.Client.IFullWhetherForecast。

Step 4:建立Proxy

SimpleWhetherForecastClient.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using Artech.InheritanceHierarchy.BusinessEntity;

namespace Artech.InheritanceHierarchy.Client
{
public class SimpleWhetherForecastClient:ClientBase,ISimpleWhetherForecast
{
ISimpleWhetherForecast Members#region ISimpleWhetherForecast Members

public BasicWhetherInfo GetBasicWhetherInfo(string postalcode)
{
return this.Channel.GetBasicWhetherInfo(postalcode);
}

#endregion
}
}

FullWhetherForecastClient.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace Artech.InheritanceHierarchy.Client
{
public class FullWhetherForecastClient:SimpleWhetherForecastClient,IFullWhetherForecast
{

IFullWhetherForecast Members#region IFullWhetherForecast Members

public Artech.InheritanceHierarchy.BusinessEntity.WindInfo

GetWindInfo(string postalcode)
{
return this.Channel.GetWindInfo(postalcode);
}

#endregion
}
}

现在通过SimpleWhetherForecastClient和FullWhetherForecastClient完全以OO的方式优雅地调用Whether forecast service。

【责任编辑:碧海蓝天 TEL:(010)68476606】


共7页: 上一页 [1] [2] [3] [4] [5] [6] 7
【内容导航】
关于 WCF  SOA  OOP  继承  Contract
专题
透析SOA的技术支持
SOA实施之路
全面解构SOA技术理念
SOA 面向服务架构
体验Visual Studio 2008的魅力
我也说两句

匿名发表

(如果看不清请点击图片进行更换)


中 国 领 先 的 IT 技 术 网 站 ·
技 术 成 就 梦 想
·Java基础教程 (查看70064次)
·UML类图详解 (查看63824次)
·UML统一建模语言 (查看34724次)
·C#技术开发指南 (查看33097次)
·Java编程开发手册 (查看31063次)
·Java编程开发手册 (1196个砖)
·Java基础教程 (429个砖)
·C#技术开发指南 (309个砖)
·.NET开发手册 (240个砖)
·PB开发教程 (223个砖)
·Java编程开发手册 (654个好)
·Java基础教程 (574个好)
·.NET开发手册 (271个好)
·PB开发教程 (212个好)
·Delphi开发技术手册 (188个好)
订阅技术快讯
电子杂志下载
名称:SQL Server数据库管理精品黄皮书
简介:书中文章经过精挑细选,便于用户能根据自己的实际工作和学习,快速在本书寻找到相关资料。内容涵盖了SQL Server的安装与升级、语句查询、数据备份和恢复、自动化任务、数据同步、数据字典、安全和预防、性能和优化、集群等各方面应用信息,以及DBA管理人员在数据库管理工作中
名称:2007路由技术大全
简介:《2007路由技术大全》由51CTO.com网站特别策划制作,该书包括路由器技术、路由器产品、路由器配置、安全设置、路由器故障处理、路由器密码恢复,以及广大网友在实践使用中的心得经验和技巧文章,内容注重实用性,适用于初学者入门,也适合多年从业者提高,是一本实践和理论完
名称:网络安全精品应用黄皮书
简介:《2007精品网络安全黄皮书》包括了9个大类24个小类, 800余篇文章,内容包含了熊猫烧香病毒、DDOS攻击、ARP病等热点问题的介绍及解决方案。从病毒查杀、防范、系统、数据等各方面的安全设置到黑客技术的了解、防范,涉及到了安全应用的全部领域, 由浅至深内容全面。