我怎么可以连接谷歌应用程序引擎的应用程序与我的Andr​​oid?应用程序、我的、引擎、我怎么

2023-09-05 04:54:19 作者:为你倾尽一世

我已经部署在谷歌应用程序,engine..it一个应用程序有一个登记表。 现在,我已经在我的Andr​​oid应用程序做了一个登记表,我想,在点击提交...它应该被发送到谷歌应用程序引擎的应用程序,它应该在特定的分贝坚持......

I've a application deployed on google app-engine..it has a registration form. now i've made a registration form in my android application and i want that on click submit...it should be sent to the application on google app-engine and it should be persisted in the particular db...

有人告诉我使用HTTP请求和响应的方法,但我不知道那个东西.. 可有人请我提供一些示例code什么的.....

somebody told me to use http request and response method but i'm not aware of that thing.. can somebody please provide me with some sample code or something.....

thanksss ....

thanksss....

推荐答案

您还没有,如果你使用Python或Java中。

You haven't specified if you're using Python or Java.

您必须决定要如何连接。最简单地说,你可以只将POST数据到谷歌应用程序引擎。在Java中,你会写它处理这个​​一个servlet。请参阅Java EE教程[http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html。或者您可以编写用于处理数据从应用程序发送的服务器上的Web服务(SOAP,REST风格)。此外谷歌这一点,有无数的例子。

You have to decide how you want to connect. At the simplest level you could just POST the data to Google App Engine. In Java you would write a servlet which handles this. See Java EE tutorial[http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html]. Alternatively you could write a web service (SOAP, RESTful) on the server which handles the data being sent from your application. Again Google this and there are countless examples.

假设我们一起走下去的最简单的POST路线。因此,在你的servlet(GAE上运行),你有这样的事情:

Assume we're going down the simplest POST route. So in your servlet (running on GAE) you'd have something like this:

public void doPost(HttpServletRequest request, 
        HttpServletResponse response) throws ServletException, IOException {

      String value1 = request.getParameter("value1");
}

而在你的Andr​​oid应用程序,你会做这样的事情:

And in your android app you'd do something like:

DefaultHttpClient hc=new DefaultHttpClient();
ResponseHandler <String> res=new BasicResponseHandler();
HttpPost postMethod=new HttpPost("http://mywebsite.com/mappedurl");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();  
nameValuePairs.add(new BasicNameValuePair("value1", "Value my user entered"));  
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));  
String response=hc.execute(postMethod,res);

在servlet的过程值1将被设置为珍惜我的用户输入。

Of course value1 in the servlet would be set to "Value my user entered".

编辑:现在谷歌已经发布了自己的谷歌云端点 - 这使得在App Engine构建RESTful服务和创造客户为Android轻松了许多。它更是尽管把你绑到App Engine的 - 但肯定值得考虑的。

Google have now released their Google Cloud Endpoints - this makes building RESTful services on App Engine and creating clients for Android a lot easier. It does tie you in to App Engine even more though - but certainly worthy of consideration.

 
精彩推荐
图片推荐