简体   繁体   English

如何使用Web服务?

[英]How use web services?

I would ask a semi-theorical question about web services and client-server architecture. 我会问一个关于Web服务和客户端 - 服务器架构的半理论问题。

I have a server with a database with about 50 tables. 我有一个服务器,数据库有大约50个表。 This server holds even one table which contains information about users associated with the clients. 此服务器甚至包含一个表,其中包含有关与客户端关联的用户的信息。 Each client has associations with a subset of all data in db. 每个客户端都与db中所有数据的子集关联。

The defined architecture implies that each client (running on Android app) calling ,with a predefined frequency, a certain number of Web Services, fill the local database, creating a copy of all the tables residing on server sb, containing the only information related to the requesting client. 定义的体系结构意味着每个客户端(在Android应用程序上运行)以预定义的频率调用一定数量的Web服务,填充本地数据库,创建驻留在服务器sb上的所有表的副本,其中包含与之相关的唯一信息。请求客户。

Furthermore, the data in db server side can change, so frequent synchronization is required. 此外,db server端的数据可能会发生变化,因此需要频繁的同步。

Considering that the client application can be imaginated as a shop online application, so should be possible browsing through providers, articles, make a order,remove orders etc. 考虑到客户端应用程序可以被想象为商店在线应用程序,因此应该可以浏览提供商,文章,订单,删除订单等。

So, when I talk about fill the local database I mean store providers, articles, ...that is, all information realated to the requesting client. 所以,当我谈到填充本地数据库时,我指的是商店提供商,文章......,即所有信息都与请求客户有关。

Can make sense fill the local database with this information? 有意义的是用这些信息填充本地数据库吗?

I think that is more reasonable call a web service only exactly when the information is required, and not store information in local db. 我认为仅在需要信息时才更合理地调用Web服务,而不是在本地数据库中存储信息。 So, synchronization is no more required. 因此,不再需要同步。

Tall me what you think about ? 高举我的想法? thank you. 谢谢。

I know NOTHING about Android development, but have tons of experience with using web services and SOA. 我对Android开发知之甚少,但在使用Web服务和SOA方面拥有丰富的经验。

In my experience, especially when the client device has limited storage and processing power, all the business logic and data logic should be in the web services, and the client app used only for display and calling those services. 根据我的经验,特别是当客户端设备具有有限的存储和处理能力时,所有业务逻辑和数据逻辑应该在Web服务中,并且客户端app仅用于显示和调用这些服务。 How you implement that is something that we can't answer for you. 你如何实现这是我们无法回答的问题。 It's different on every project. 每个项目都有所不同。

The only exception is when you absolutely have to have the app running while not connected. 唯一的例外是你必须在没有连接的情况下运行应用程序。 In that case, be sure you know your specific requirements, and be very dilligent to only persist at the client the data that you absoutely need , and only provide the business logic that you absolutely need while disconnected. 在这种情况下,要确保你知道你的具体要求,并很dilligent仅在客户端仍然存在,你absoutely需要的数据,并且只提供你绝对需要断开连接时的业务逻辑。

(This helps to keep security simpler as well - lost or stolen devices are one of the highest sources of data breaches, so the less potentially sensitive data on the device the better.) (这有助于保持安全性更加简单 - 丢失或被盗的设备是数据泄露的最高来源之一,因此设备上潜在敏感数据越少越好。)

I don't know if that's helpful, but I throught I'd throw it out there. 我不知道这是否有用,但我会把它扔出去。

If your application is going to work only online, then YES. 如果您的应用程序仅在线工作,那么YES。 You don't need to worry to store the data into the database and retrieve it later. 您无需担心将数据存储到数据库中并在以后检索它。 If your requirement that needs to support both online and offline, then you have to go withe the database. 如果您的需求需要同时支持在线和离线,那么您必须使用数据库。

You can run a service or Async task or Handlers to invoke the Webservice from the Android Application, that way your UI thread won't be blocked. 您可以运行服务或异步任务或处理程序来从Android应用程序调用Web服务,这样就不会阻止您的UI线程。

If your response is too big, then probably you have to think about middle tier, that way you can convert the SOAP response to JSON that would be easier for the device to process the response and network transmission is faster. 如果您的响应太大,那么您可能需要考虑中间层,这样您就可以将SOAP响应转换为JSON,以便设备更容易处理响应并且网络传输更快。

I believe based on your requirements, its good enough to support only online mode... Because the data might vary if the user is not using the app for two days and logs in back and show offline data that might be irrelevant 我相信根据您的要求,它足以支持仅在线模式...因为如果用户两天没有使用该应用程序并且登录后显示可能不相关的离线数据,数据可能会有所不同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM