Android 如何在GAE上仅创建和使用没有客户端的SOAP服务器?

Android 如何在GAE上仅创建和使用没有客户端的SOAP服务器?,android,google-app-engine,Android,Google App Engine,首先,对不起,我的英语很差。 我找到了这篇文章,并按照它。 成功了。现在我只想创建这样的服务器,以便在其他客户端中使用。可以吗? 例如,当我将HelloSoAppServerServlet部署到abc@appspot.com 当我想使用我的服务时,我只需粘贴以下URL:abc@appspot.com/hellosoapserver?name=SOAP&riming=true,适用于浏览器。我怎么能做那样的事? 因为我想让我的客户使用的是Andoird手机。abc@appspot.com是一个

首先,对不起,我的英语很差。 我找到了这篇文章,并按照它。

成功了。现在我只想创建这样的服务器,以便在其他客户端中使用。可以吗? 例如,当我将HelloSoAppServerServlet部署到abc@appspot.com 当我想使用我的服务时,我只需粘贴以下URL:abc@appspot.com/hellosoapserver?name=SOAP&riming=true,适用于浏览器。我怎么能做那样的事?
因为我想让我的客户使用的是Andoird手机。

abc@appspot.com
是一个电子邮件地址。您不能将GAE代码部署到它

创建应用程序时,必须选择唯一的应用程序名称,例如
mysoap
。然后,您的应用程序的url将为
http://mysoap.appspot.com/


访问它之后,您可以在
http://mysoap.appspot.com/hellosoapserver?name=SOAP&arriving=true

您在该示例中得到了它

您在中创建了SOAP Web服务:

在Google App Engine上构建SOAP服务器

然后您创建了一个从Servlet使用它的客户机:

使用JAX-WS在Google App Engine上构建SOAP客户端

现在,您需要的是使用params中的正确值从Android应用程序对该URL进行HTTP客户端调用

使用您的示例提供的示例和url

   URL url = new URL(" http://greeter-client.appspot.com/hellosoapclient?name=SOAP&arriving=true");
   HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
   try {
     InputStream in = new BufferedInputStream(urlConnection.getInputStream());
     readStream(in);
    finally {
     urlConnection.disconnect();
   }
readStream中,您可以从GAE托管的服务中读取响应

readStream可以是这样的:

private static String readStream(InputStream is) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();

    String line = null;
    try {
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return sb.toString();
}

非常感谢你。我试试看