本文介绍了在Android客户端服务器通信选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前是在我的论文项目的研究阶段。

我的项目是针对移动设备的订票系统,我选择了针对Android的。

我预计需要与中央服务器的客户机/服务器架构,所以我目前正在研究如何将Android这样的服务器进行通信。服务器将授予票务信息的客户端访问,客户端会发送有关机票预订到服务器的信息。我在看的Java EE服务器作为Java是我最有经验的语言。

我知道,Android自带有的java.nio java.net ,以及一些 org.apache 包,但我也正在寻找这将有可能与Android使用的库/技术。

到目前为止,我没有发现任何在互联网上大量的帮助,让我看到什么那么可以建议。

我特别有兴趣知道:

       
  1. 是有不同的中间件技术在Android中哪些支持?例如      
               
    • 基于RPC的中间件
    •          
    • CORBA
    •          
    • 在消息中间件
    •          
    • 在Web服务,如XML-RPC,SOAP,REST
    •       
       
  2.    
  3. 如何好(或没有)就现有的Java库在Android平台上使用时的工作? (例如,如果我想用一个库/ API设计的Java SE,而不是Android的我可能会遇到什么问题?)

在理想情况下,为我的项目的重点并不意味着在服务器和客户机之间的通信,我可以使用现有的中间件来处理通信,但我ppared为最坏的情况下,$ P $,这是有写我自己的。

解决方案

我个人的看法 - 尽管我不觉得我是一个人在这样想的 - 是唯一的协议,专门设计用来在互联网上运行的远程适合与移动客户端使用。你的列表所以,唯一一个我甚招待是:

有些人一直保持着kSOAP2的一个Android端口。不过,我得到了这方面的工作大部分Android开发者都倾向于对REST和REST十岁上下的协议不同的IM pression。如果不出意外,这什么都好玩的网站和服务正在使用的API,使用XML-RPC(旧)和SOAP(旧的和过甜的),特别是相比的。

我已经成功地使用这两个 java.net.URLConnection中和Apache了HTTPClient在Android中与REST风格的端点通信库 - 直接或通过第三方的JAR - 没有真正的Andr​​oid特有的问题

有难以回答,在抽象。 Android的实现JavaSE的大幅一部分,但不是全部的JavaSE的,所以这是一个机会,任何给定的JAR会想到一些Android不提供。同样,Android不使用环境变量,命令行开关,或各种开发人员集中在桌面上可能已经引入了半要求的其他事情。所以,有些东西对我来说曾与比重新编译(BeanShell的)而已,有些事情已经删除冗余班组长(JTwitter)后的工作对我来说,有些事情看起来像他们将是可怕的,以获得工作(的JavaMail)

I'm currently in the research phase of my dissertation project.

My project is a ticket booking system for a mobile device and I have chosen to target Android.

I anticipate the need for a client/server architecture with a central server, and so am currently looking at how Android could communicate with such a server. The server would grant the client access to ticketing information, and the client would send information about ticket bookings to the server. I'm looking at Java EE for the server as Java is the language I'm most experienced with.

I'm aware that Android comes with java.nio and java.net, as well as some org.apache packages, but am also looking for libraries/technologies that would be possible to use with Android.

So far I've not found anything massively helpful on the internet, so I'm seeing what SO can suggest.

Specifically I am interested in knowing:

  1. What support is there for various middleware technologies in Android? e.g.
    • RPC based middleware
    • CORBA
    • Message based middleware
    • Web services such as XML-RPC, SOAP, REST
  2. How well (or not) do existing Java libraries work when used on the Android platform? (e.g. If I wanted to use a library/API designed for Java SE rather than Android what problems might I encounter?)

Ideally, as the focus of my project isn't meant to be the communication between the server and client, I could use an existing middleware to handle the communication, but I am prepared for the worst case, which is having to write my own.

解决方案

My personal opinion -- though I do not feel I am alone in thinking this way -- is that only protocols specifically designed to run over the Internet are remotely suitable for use with a mobile client. So, of your list, the only one that I would even entertain would be:

Some people have been maintaining an Android port of kSOAP2. However, I get the distinct impression that most Android developers working in this area have tended towards REST and REST-ish protocols. If nothing else, that's what all the fun Web sites and services are using for an API, particularly compared with XML-RPC (old) and SOAP (old and icky).

I have successfully used both the java.net.URLConnection and Apache HTTPClient libraries in Android for communicating with REST-style endpoints -- both directly and through third-party JARs -- with no real Android-specific issues.

It is difficult to answer that in the abstract. Android implements a substantial subset of JavaSE, but not all of JavaSE, so there's a chance that any given JAR will expect something Android does not offer. Similarly, Android does not use environment variables, command-line switches, or a variety of other things that developers focused on the desktop might have introduced as semi-requirements. So, some things have worked for me with nothing more than a recompile (Beanshell), and some things have worked for me after removing redundant classs (JTwitter), and some things looked like they were going to be ghastly to get working (JavaMail).

这篇关于在Android客户端服务器通信选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:56