0

通常は、Google で解決策を探してエラーを修正できますが、エラー メッセージが表示され、エラーを見つけることができません。コードは次のとおりです。

private void login(String Action, String User, String Password) {
    // TODO Auto-generated method stub
        start = false;
        //get ip
        String ip = getIPAddress(true);
        //get Location
       // locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 400, 10, this);
        //get phone number
        TelephonyManager manager =(TelephonyManager)LoginActivity.this.getSystemService(Context.TELEPHONY_SERVICE);
        String myPhoneNumber = manager.getLine1Number();
        Message msg = handler.obtainMessage();
        Bundle bundle = new Bundle();
        httppost = new HttpPost("http://www.office.school-blog.de/api/check-login.php");
        HttpParams httpParameters = new BasicHttpParams();
        // Set the timeout in milliseconds until a connection is established.
        // The default value is zero, that means the timeout is not used. 
        int timeoutConnection = 15000;
        HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
        // Set the default socket timeout (SO_TIMEOUT) 
        // in milliseconds which is the timeout for waiting for data.
        int timeoutSocket = 15000;
        HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
        httpclient = new DefaultHttpClient(httpParameters);
        nameValuePair = new ArrayList<NameValuePair>(1);
        nameValuePair.add(new BasicNameValuePair("Action", Action));
        nameValuePair.add(new BasicNameValuePair("User", User));
        nameValuePair.add(new BasicNameValuePair("Password", Password));
        nameValuePair.add(new BasicNameValuePair("PhoneNumber", myPhoneNumber));
        nameValuePair.add(new BasicNameValuePair("Lat", lat));
        nameValuePair.add(new BasicNameValuePair("Lon", lon));
        nameValuePair.add(new BasicNameValuePair("Ip", ip));
        try {
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePair));
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            bundle.putBoolean("Login", false );
            bundle.putBoolean("Connection", false);
            msg.setData(bundle);
            handler.sendMessage(msg);
        }
        try {
            response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            entity.consumeContent();
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String response;
        try {
        //  Toast.makeText(getBaseContext(), "test", Toast.LENGTH_LONG).show();
            response = httpclient.execute(httppost, responseHandler);
            if (response.contains("root") ^ response.contains("Schueler") ^ response.contains("Lehrer") ^ response.contains("Sekretariat") ^ response.contains("Reporter")){
                SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
                p.edit().putString("Class", response).commit();
                bundle.putBoolean("Login", true );
                bundle.putBoolean("Connection", true);
                msg.setData(bundle);
                handler.sendMessage(msg);
                //txtStatus.setText("Success");
        //      Toast.makeText(getBaseContext(), "Success", Toast.LENGTH_LONG).show();
            } else {
                bundle.putBoolean("Login", false );
                bundle.putBoolean("Connection", true);
                msg.setData(bundle);
                handler.sendMessage(msg);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            bundle.putBoolean("Login", false );
            bundle.putBoolean("Connection", false);
            msg.setData(bundle);
            handler.sendMessage(msg);
        //  Toast.makeText(getBaseContext(), "exception", Toast.LENGTH_LONG).show();
        }

    }

しかし、このコードを実行すると、org.apache.http.client.HttpResponseException: Internal Server Error が発生します。

私のログは次のとおりです。

11-14 18:13:05.340: W/System.err(462): org.apache.http.client.HttpResponseException: Internal Server Error
11-14 18:13:05.340: W/System.err(462):  at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:71)
11-14 18:13:05.350: W/System.err(462):  at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:59)
11-14 18:13:05.350: W/System.err(462):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
11-14 18:13:05.350: W/System.err(462):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
11-14 18:13:05.360: W/System.err(462):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
11-14 18:13:05.370: W/System.err(462):  at com.shr.khg.LoginActivity.login(LoginActivity.java:260)
11-14 18:13:05.370: W/System.err(462):  at com.shr.khg.LoginActivity.access$0(LoginActivity.java:204)
11-14 18:13:05.370: W/System.err(462):  at com.shr.khg.LoginActivity$2.run(LoginActivity.java:156)

誰かが私のエラーを見つけて、私が間違っていることを説明するのを手伝ってくれますか?

4

1 に答える 1

1

Webサービスが適切に応答していることを確認してください

于 2013-11-14T18:46:40.773 に答える