0
Android에서 웹 서비스에 요청을 보내려고합니다. 상태 400이 반환됩니다. 상태 400은 잘못된 요청을 의미하지만, 나는 잘못된 것을 볼 수 없습니다. 이 문제를 어떻게 해결할 수 있습니까?Http 요청 상태 400
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2:1455/Android/Android.svc/GetCompanyBusinessAreas2");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("company", companhiaIdS));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
//httppost.g
//httppost.setEntity(new StringEntity(companhiaIdS));
Log.i("Enviando:", nameValuePairs.toString());
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
Log.i("Resposta:", response.getEntity().toString());
Log.i("status","" + response.getStatusLine().getStatusCode());
HttpEntity responseEntity = response.getEntity();
char[] buffer = new char[(int) responseEntity.getContentLength()];
Log.i("buffer:","" + responseEntity.getContentLength());
try {
InputStream stream = responseEntity.getContent();
InputStreamReader reader = new InputStreamReader(stream);
reader.read(buffer);
stream.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
Log.i("EXCEPTION", e.getMessage());
}
//FIM DA LIGACAO WCF
String reply2 = new String(buffer);
Log.i("teste", reply2);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
변수 companhiaIdS은 문자열입니다
여기 내 요청 코드입니다.
서비스가 다른 유형의 매개 변수를 보내고 있음을 의미 할 수 있습니까? –
아마 그렇습니다 – Blackbelt
일반적으로 웹 서버를 디버깅하려고 할 때 "telnet * server * 80"을 통해 수동으로 요청을 실행하고 수동으로 http 요청을 입력합니다. 이것은 느리지 만 방정식에서 클라이언트 응용 프로그램을 제거하고 문제가 클라이언트의 서버에 있는지 확인할 수 있습니다. –