Android から GAE 上のサーバーに http 投稿リクエストを送信しようとしています。
Android 側では投稿がうまくいくように見えますが、サーバー側では doPost(...) が呼び出されることはありません。誰でも理由を教えてもらえますか?
関連するAndroidコードは次のとおりです。
protected Integer doInBackground(View... arg0)
{
try
{
HttpClient httpClient = new DefaultHttpClient();
// HttpPost httpPost = new HttpPost("http://elf-security.appspot.com");
HttpPost httpPost = new HttpPost("http://elf-security.appspot.com/gae_hellowordl");
// HttpPost httpPost = new HttpPost("http://localhost:8888/gae_hellowordl");
httpPost.addHeader("test", "Success!");
Log.i(TAG, "Just about to send http request to " + httpPost.getURI());
HttpResponse httpResponse = httpClient.execute(httpPost);
Log.i(TAG, "Received http response..");
Log.i(TAG, httpResponse.toString());
} catch (ClientProtocolException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
return null;
}
そして、ここに私の関連するサーバーコードがあります:
public class GAE_HelloWordlServlet extends HttpServlet
{
private Logger LOG;
public GAE_HelloWordlServlet()
{
LOG = Logger.getLogger("GAE_HelloWordlServlet");
LOG.info("GAE_HelloWordlServlet()");
}
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
LOG.info("doGet(): request test header: " + req.getHeader("test"));
}
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException
{
LOG.info("doPost(): request test header: " + req.getHeader("test"));
}
}
前もって感謝します!
編集
ここに私の web.xml ファイルがあります:
<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>GAE_HelloWordl</servlet-name>
<servlet-class>gae.helloworld.GAE_HelloWordlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GAE_HelloWordl</servlet-name>
<url-pattern>/*</url-pattern>
<!-- <url-pattern>/gae_hellowordl</url-pattern> -->
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value/>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
</web-app>