如何在移动应用程序上连接到服务器? [英] How to connect to the server on mobile application?

查看:190
本文介绍了如何在移动应用程序上连接到服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是移动应用程序的新手.我基本上来自Web开发平台.我只是在围绕移动框架(如App Framework,LungoJS,Jquery Mobile,kendo等)玩耍,以获取有关该领域的一些知识.

I am new to mobile applications. I am basically from a web development platform. I am just playing around mobile frameworks like App Framework, LungoJS, Jquery Mobile, kendo etc to gain some knowledge in this vertical.

我正在开发的应用仍处于UI级别.我所需要做的就是从服务器获取数据并填充到我的应用程序中.

The app I am developing is still in UI level. All I need is to fetch data from the server and populate in my app.

我需要一些想法来建立智能设备和服务器之间的服务器通信.我的问题是

I need some ideas to establish server communication between the smart device and the server. My questions are

  1. 移动应用程序需要哪种服务器?云还是 普通的Web服务器就足够了吗?
  2. 将应用程序与服务器连接的方式有哪些? (在十字架上 平台移动开发)
  3. 与服务器通信的安全方式是什么?
  1. What kind of server needed for mobile applications ? A cloud or a regular web server is enough ?
  2. What are the ways to connect the app with the server ? ( on cross platform mobile development )
  3. What is the secure way to communication with the server ?

推荐答案

移动应用程序需要哪种服务器?云还是普通的Web服务器就足够了?

由于您正在创建混合移动应用程序,因此可以使用任何类型的服务器端技术,这无关紧要是经典的Web服务器技术(使用Java,PHP或.NET)还是某种云技术,例如 Parse.com .

What kind of server needed for mobile applications ? A cloud or a regular web server is enough ?

Because you are creating a hybrid mobile application you can use any type of server side technology, it doesn't matter is it a classic web server technology (using Java, PHP or .NET) or some kind of cloud technology like Parse.com.

您也不需要从头开始创建任何内容.最好的做法是使用某种微型RESTFul框架(例如PHP Falcon 或Java Play框架 ).在 此处 上详细了解它们.

You also don't need to create anything from scratch. Best course of action would be to use some kind of micro RESTFul framework(like PHP Falcon or Java Play Framework). Read more about them here.

但是,总是有一个but.您不能将服务器端技术用于经典内容的生成,仅需要使用它来将数据发送到混合应用程序.我待会再解释.

But, there's always a but. You can't use server side technology for classic content generation, you only need to use it to send data to your hybrid application. I will explain this later.

还有RESTFul服务的替代方法,您可以再次使用Java,PHP或.NET创建Web服务.

There's also an alternative to RESTFul services, you can create a webservice, again using Java, PHP or .NET.

您将使用AJAX作为一种技术(对于RESTFul),其余取决于您.您可能会以JSON格式执行此操作(如果正在进行跨域调用,则可以使用JSONP,但在创建混合应用程序时无需考虑JSONP).

You would use AJAX as a technology (in case of RESTFul), rest depends on you. You would probably do it in JSON format (or JSONP if you are doing cross-domain calls, but you don't need to think about JSONP when creating a hybrid application).

如果打算使用Web服务,则可以使用SOAP连接并通过XML格式进行通信.

If you intend to use a web service then you would use a SOAP connection and communicate via XML format.

无论您使用哪种服务器端技术,都将始终在客户端上使用AJAX.

No matter which server side technology you use you will always use AJAX on a client side.

现在让我告诉您为什么不应该在服务器端生成内容.基本上没有什么可以阻止您这样做,您可以在Web服务器上生成完整的页面,然后仅在PhoneGap应用程序中显示它,它仍然是混合应用程序.但是,如果您尝试将此应用程序放入Apple Store,则会遭到拒绝.

Now let me tell you why you should not generate your content on server side. Basically nothing can prevent you from doing that, you can generate your complete page on web server and just show it in PhoneGap app, it would still be a hybrid app. But, if you try to put this app in Apple store you will get yourself rejected.

安全性当然取决于服务器端技术.每个框架都有其自身的安全处理方式,但是它们都基于HTTPS进行中继,因此您不必担心太多.

Security of course depends on server side technology. Every framework has its own kind of security handling, but all of them relay on HTTPS so you should not worry too much.

您始终可以从客户端加密JSON/XML数据并使用POST发送它们.

From the client side you can always encrypt JSON/XML data and send them using POST.

如果您想使用jQuery Mobile,请查看 教程.它将向您展示客户端-服务器端通信的基础知识.

If you want to use jQuery Mobile then take a look at this tutorial. It will show you basics of client - server side communication.

这篇关于如何在移动应用程序上连接到服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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