与RESTful Services中的客户端共享业务对象 [英] Sharing business objects with client in RESTful Services

查看:81
本文介绍了与RESTful Services中的客户端共享业务对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个站点,我们正在使用REST体系结构.

有些业务对象需要在客户端和服务器之间共享.

我对面向对象的代码非常特别.因此,我的业务对象中定义了方法.

例如,我有一个Employee对象.我正在与客户分享.

当客户端调用Employee.getData()时,该方法将与REST服务对话并向我返回数据.

在服务器调用Employee.getData()的同时,该方法将与数据库对话并返回数据.

有人可以在不使用扩展方法的情况下阐明一些实现方法.

在这种情况下,是否有任何最佳的设计模式?

Girish

I am developing a site and we are using REST architecture.

There are business objects that needs to be shared between the client and the server.

I am very particular about Object Oriented code. So my business objects have methods defined in it.

Example, I have a Employee object. I am sharing this with client.

When the client calls Employee.getData(), the method will talk to the REST Service and returns me the data.

At the same time when the server calls Employee.getData(), the method will talk to the database and return the data.

Can somebody please throw some light on how to implement this without using extension methods.

Is there any design pattern that works best in this case?

Girish

推荐答案

好吧,这实际上不是在客户端应用程序中使用REST服务的方式. REST服务调用是纯HTTP调用,它以XML/JSON格式返回数据.

请查看下面的链接,以获取有关" REST "的信息.

http://en.wikipedia.org/wiki/Representational_state_transfer

http://msdn.microsoft.com/en-us/library/dd203052.aspx

http://msdn.microsoft.com/en-us/netframework/cc950529

您可以将多层体系结构用于您的业务逻辑和数据访问代码.

C#.NET中的三层体系结构

设计模式的选择完全取决于您的业务需求,我建议您确保您正确地遵循了面向对象编程的基础.

面向对象编程概念(OOP)和更多内容的介绍
Well, this is really not how REST services are consumed in Client Application. REST service call is a pure HTTP call which returns Data in a XML/JSON format.

Have a look at below links for information on "REST".

http://en.wikipedia.org/wiki/Representational_state_transfer

http://msdn.microsoft.com/en-us/library/dd203052.aspx

http://msdn.microsoft.com/en-us/netframework/cc950529

You may use Multi-Tier architecture for your Business Logic and Data-Access code.

Three Layer Architecture in C# .NET

Selection of Design Pattern totally depends on your business requirements, I will suggest you just make sure you are following fundamentals of Object Oriented Programming properly.

Introduction to Object Oriented Programming Concepts (OOP) and More


这篇关于与RESTful Services中的客户端共享业务对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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