0

http POST リクエストを実行するために、次の関数を作成しました。

private void httpPost(final File xmlFile){
    String textviewresponse;
    Thread thread = new Thread(){
        @Override
        public void run() {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost("http://myURL");
            StringEntity entity;
            HttpResponse httpresponse;

            try {
                entity = new StringEntity(xmlFile.toString());
                entity.setContentType("text/xml");
                Log.d("TAG",httppost.getURI().toString());
                httppost.setEntity(entity);

                try {

                    httpresponse = httpclient.execute(httppost);
                    textviewresponse=EntityUtils.toString(httpresponse.getEntity()); 
                    Log.d("TAG",textviewresponse);


                } catch (ClientProtocolException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();    
                }finally {
                    httpclient.getConnectionManager().shutdown();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };

    thread.start(); 
}

問題は、リクエストを送信すると、POST に対して取得する必要があるものではなく、GET メソッドの応答を取得し続けることです。

この問題の原因は何ですか?

4

0 に答える 0