客户端类库与Web服务/ Web服务与服务器类库之间的通信 [英] Communication between client class library and web service / web service and server class library

查看:277
本文介绍了客户端类库与Web服务/ Web服务与服务器类库之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道别人做什么/最好的做法来进行层之间的沟通。这个问题涉及2-3层和3-4层之间的沟通。



我们的基础架构(按顺序)如下:


  1. UI

  2. 前端业务类

  3. Web服务

  4. 后端业务课程

  5. DAL

Web服务只是一个外观,包括记录和身份验证到后端类库。



因此,Web服务被传递一个请求对象,其中包含web方法所需的参数以及用户凭据(例如,用户凭据存储在基类,因为我们将永远需要将其传递给webservice),并响应对象(具有诸如状态和消息,如果失败等等以及需要的对象),请求&响应使用只返回一个结果的自定义通用类/或接口,否则需要创建一个类。



有时在第4层对响应对象执行此操作是有意义的(尽管我们不使用请求对象,除非有很多参数需要pasaws)在这种情况下,我们在第3层中只有一个适配器类,将其返回给客户端。为了保持一致性,我已经考虑过这样做,尽管认为这可能是过度的。



所以为了迭代这个问题,层间沟通的最佳做法是什么?并且应该/人们使用上面概述的方法(它对我们有效),并且层3-4应该实现类似于2-3的方法?



可能的注意事项: / p>


  • 目前,所有内容都由开发人员团队编写,有些客户端代码可能会在未来外包

  • 未来的网络服务将基于WCF(不知道这个效果设计,而不是编码到我更喜欢的接口)。
  • 我们使用.net


解决方案

为了完整起见:



如果要将Web服务更改为WCF,那么在类库中具有响应/请求似乎是个好主意,有少做工作。


Wondering what others do / best practice for communicating between layers. This question relates to communication between layers 2-3 and 3-4.

Our Basic Architecture (in order) as follows:

  1. UI
  2. Front End Business Classes
  3. Web Services
  4. Back End Business Classes
  5. DAL

The web services are just a façade that include logging and authentication to back end class libraries.

As such, the web service is passed a request object that includes the parameters required by the web method along with the user credential (the user credential for example is stored in a base class as we will always need to pass this to the webservice) and responds with response objects (has things such as status and message, if failed etc along with the object required) both request & response use a custom generic class/or interface where only one result is returned, otherwise a class needs to be created.

Sometimes it makes sense to do this for the response object at layer 4 (though we don't use a request object unless a lot of parameters need to be pasaws), in which case we just have an adapter class in layer 3 which returns this to the client. For consistency I have considered doing this all the time, though think it may be overkill.

So to iterate the question, what are the best practices for communicating between layers? and should/do people use this method outlined above (it works well for us) and should layers 3-4 implement similar method to 2-3?

Possible considerations:

  • currently everything is coded in house by a team of developers, some client code may be outsourced in the future
  • future web services will be WCF based (not sure if that effects design other than coding to interfaces which I would prefer anyway).
  • We use .net

解决方案

For the sake of completeness:

It seems a good idea to have the response / requests in the class library, that way if you want to change the web service to WCF, there is less work to do.

这篇关于客户端类库与Web服务/ Web服务与服务器类库之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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