简体   繁体   中英

Object transfer between client server

We have a java client/server environment for our business applications and we would like to create a mobile app for our employees.

We currently have a prototype client application running on iOS (iPhone/iPad) that talks to our java server via sockets. Simple queries as passed in via strings, and the server responds back sending string/list of strings. However, this is quite painful as we would like to send actual data objects ie Lists, Map, etc.

What is the best way of transferring data between the server (java) and client (objective C)? The java server isn't java EE... so there's no tomcat/servlets involved. From what I found online, other companies use JSON to achieve this. I am not really sure how to go about doing this, or whats the best method out there.

I would look at providing a series of web services (basically these would look like normal http GET or POST commands to the client) that would either respond with XML or JSON formatted responses, the requirements would depend on what you have available on the client I guess (you could do both and use a parameter as part of the request to change the format)

Take a look at Web Service for more details.

The basic requirement would be to standardise your input and and output in such as way as it would not matter what client you were connecting with

This also means that you would be (potentially) communicating via standard ports and the all the messy protocol stuff is taken care for you.

Can do this using Tomcat and servlets, which adds another layer between the client and the database. This means that requests coming in, especially requests that modify the database have to pass through, at least, one more layer before hitting the database, allowing you to centralise the business logic (which I assume you've already done) and guard the database

Search for JSON serializer libraries implemented in Java and Objective-C. While JSON is not the most compact or efficient data representation, it's very a convenient format to use between clients and servers because it's ubiquitous and also easily readable by humans. Avoid XML - it's unnecessarily complicated if you own both the client and the server components.

In the long run I agree it may make the most sense to look at migrating to standard Web Services that run in a container like Tomcat.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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