Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Web服务没有响应_Android_Web Services - Fatal编程技术网

Android Web服务没有响应

Android Web服务没有响应,android,web-services,Android,Web Services,我有一个问题,我正在调用一个运行在Google Chrome RESTClient插件软件上的Web服务,并给出200个响应,但当我在Android应用程序中调用相同的服务时,它没有响应 我不知道Android有什么问题。请告诉我正确的结果 谢谢 错误堆栈 09-27 10:41:14.582: INFO/System.out(373): <HTML><TITLE>404 Not Found</TITLE><BODY><H1>404 N

我有一个问题,我正在调用一个运行在Google Chrome RESTClient插件软件上的Web服务,并给出200个响应,但当我在Android应用程序中调用相同的服务时,它没有响应

我不知道Android有什么问题。请告诉我正确的结果

谢谢

错误堆栈

09-27 10:41:14.582: INFO/System.out(373): <HTML><TITLE>404 Not Found</TITLE><BODY><H1>404 Not Found</H1><P>Unable to connect to host</BODY></HTML>
09-27 10:41:14.582: WARN/System.err(373): org.json.JSONException: Value <HTML><TITLE>404 of type java.lang.String cannot be converted to JSONObject
09-27 10:41:14.582: WARN/System.err(373):     at org.json.JSON.typeMismatch(JSON.java:107)
09-27 10:41:14.582: WARN/System.err(373):     at org.json.JSONObject.<init>(JSONObject.java:158)
09-27 10:41:14.582: WARN/System.err(373):     at org.json.JSONObject.<init>(JSONObject.java:171)
09-27 10:41:14.582: WARN/System.err(373):     at com.equinix.android.parsing.Parse_Json.parse_ShowOrders(Parse_Json.java:323)
09-27 10:41:14.582: WARN/System.err(373):     at com.equinix.android.showmyorders.ShowMyOrders$2.run(ShowMyOrders.java:112)
呼叫服务方式:

 try{
                               HttpPost post = new HttpPost("http://qa.mobile.equinix.com/eqixmobile/siteservice/order/getsitevisitsByCustOrgId");
                               StringEntity se = new StringEntity("{\"userKey\":\"68782\",\"custOrgId\":\"37\",\"credentials\":{\"password\":\"welcome1\",\"username\":\"mobileuser1\"},\"ibxCode\":\"SV1\",\"orderStatusList\":[\"SAVED\",\"SUBMITTED\"],\"pagination\":{\"pageNo\":1,\"pageSize\":6}}");
                               obj = new Service_Call(post, se, "mobileuser1", "welcome1",false);                                 
                               String json_string = obj.call_Service();
                               new Parse_Json(json_string).parse_ShowOrders();
                           }catch(Exception e)
                           {
                               e.printStackTrace();
                           }
package com.equinix.android.servicecall;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;

import com.equinix.android.common.MenuScreen;
import com.equinix.android.parsing.Parse_Json;

import com.equinix.android.parsing.Parse_Json;
import com.equinix.android.sitevisit.Site_Visit_Details;

public class Service_Call {

    HttpPost post;
    StringEntity eq_Credentials;
    String usr_Name,pass;
    boolean flag;
    public static int status_code=0;
    public Service_Call(HttpPost post,StringEntity eq_Credentials, String usr_Name, String pass,boolean flag)
    {
        this.post = post;
        this.eq_Credentials = eq_Credentials;
        this.usr_Name = usr_Name;
        this.pass = pass;
        this.flag = flag;
    }

    public String call_Service()
    {
          HttpClient client = new DefaultHttpClient();
          HttpConnectionParams.setConnectionTimeout(client.getParams(), 20000); //Timeout Limit
          HttpResponse response;

          try{
             // HttpPost post = new HttpPost("http://122.180.114.68/eqixmobile/siteservice/um/ibx");
           if(flag)
           {

              eq_Credentials.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
              post.setEntity(eq_Credentials);

              response = client.execute(post);
              System.out.println("The request body:"+post);
           }
           else
           {
               post.setHeader("Content-type", "application/json");
               post.setHeader("accept", "application/json");
               eq_Credentials.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));

               post.setEntity(eq_Credentials);

               response = client.execute(post);
               System.out.println("The request body:"+post.toString());
               status_code = response.getStatusLine().getStatusCode();
               System.out.println("The Response Code:"+response.getStatusLine().getStatusCode());
           }



                  BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
                  StringBuilder builder = new StringBuilder();
                  String str=""; 

                  String line = null; 
                   while ((line = reader.readLine()) != null) { 
                      str +=line; 

                   }


                 System.out.println(str);


                 return str;
          }
          catch(Exception e){
              e.printStackTrace();

          }
       return null;
    }
}

请从代码中删除以下行

*eq_Credentials.setContentEncoding(新的BasicHeader(HTTP.CONTENT_类型,“application/json”)*


希望这对您有所帮助。

如果您需要帮助,请显示您正在使用的代码。是的,我提供了它,请查看编辑后的代码