开发者

Communication between client class library and web service / web service and server class library

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 Busi开发者_JAVA技巧ness 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜