.NET中使用WCF的3层 [英] 3 tier using WCF in .Net

查看:88
本文介绍了.NET中使用WCF的3层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在vb.net 2008中开发了一个三层应用程序,该应用程序具有用户界面层,业务层和数据访问层.

现在,我想在线分发该应用程序.我决定使用WCF托管服务.

我在网上阅读了更多有关WCF的文章.我了解到在WCF中可以承载单个服务类.但是我们可以使用多个接口和多个数据协定.

但是在我的应用程序中,我无法决定如何为我的应用程序创建服务主机.

我解释一下我的头像.
客户端应用程序包含UI和BL-在客户端计算机中
WCF服务应用程序在服务器计算机中启用DL
BL和DL通过WCF进行通信

用户界面包含更多表单(超过50个),每个表单具有不同的数据合同

但是所有形式都具有一些与DL通讯的通用功能

因此,我决定将我的服务合同定义为以下所有形式的通用合同



I have developed a 3 tier application in vb.net 2008 which has User Interface Layer, Business Layer and Data Access Layer.

Now I want to distribute the application in online. I have decided to host the service using WCF.

I have read more articles in the net about WCF. I have learned In WCF single Service Class can host. But we can use multiple interface and multiple data contracts.

But in my application I can''t decide how to create service host for my application.

I explain my senerio.
The client application contains UI and BL - in client machine
The WCF service application caontains DL - in server machine
BL and DL communicate via WCF

UI contains more forms ( more than 50) each one have different data contracts

but all forms have some common functions to communicate to DL

so I have decided to define my service contract as common for all forms as below

<servicecontract()> _
 Public Interface SetupMasterFrmServiceContract

      <operationcontract()> _
      Sub DataNew()

      <operationcontract()> _
      Function DataProcess(ByVal xdata As Combositetype,ByVal xMode As Char) As Boolean

      <operationcontract()> _
      Sub DataOpen(ByVal x As String)

      <operationcontract()> _
      Sub DataFetch()

  End Interface



但在上面的代码中,



but in the above code in the line

Function DataProcess(<b>ByVal xdata As Combositetype</b>,ByVal xMode As Char) As Boolean



每种形式的组合位型都不同.如何定义所有表格的服务合同.如果我为每种形式都声明接口,那么实现服务类非常浪费.
请说明如何声明和定义我的服务合同.



the combositetype is vary for every form. how can I define the service contract for all forms. If I declare interface for every form then it is very vauge to implement the service class.
Please explain how to declare and define my service contract.

推荐答案

应用程序应在不同域\模块之间中断UI,然后基于此可以定义公用数据您可以在其中使用的合同.

如果您打算对所有UI使用单个服务,则作为Combositetype传递的数据应具有一个所有UI都通用的父类.
您可能必须在Combositetype中添加另一个属性,该属性可以唯一地标识数据的来源形式.

希望对您的决定有所帮助...
The Application should break the UIs among different domains \ modules and then based on that you can define the common data contract that you can use in them.

In case you plan to use a single service for all UIs, the data being passed as Combositetype should have a parent class which is common for all the UIs.
You may have to add an another property in the Combositetype which can identify uniquely the data as to from which form it is coming from.

Hope its helpful to make your decision...


这篇关于.NET中使用WCF的3层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆