2016-10-04 75 views
-11

請參閱以下網址什麼是在Android Studio中的代碼

http://courierdirect.improweb.com/WSPost/Default.aspx?id=Authenticate&[email protected]&password=test123

這將返回一個JSON對象像下面。

{ 
    "UserID": "1", 
    "Username": "[email protected]", 
    "Token": "KOSEPO1DSJSMVIF3JNHGGG4SBVKW3QVNMKNI0Q1FN18SWDOL2L" 
} 

會是怎樣的代碼得到響應

+1

我投票關閉這一問題作爲題外話因爲這不是要求人們編寫代碼的地方。 – AndroidMechanic

+0

你到目前爲止所嘗試過的。 https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=android%20http%20get%20with%20參數鏈接將幫助您 – Anjali

回答

0

如果你使用SOAP折騰這樣的:

 String namespace = "http://tempuri.org/" ; 
    String soapAction = "http://tempuri.org/MyMethod"; 
    String methodName = "MyMethod"; 
    String url = "http://192.168.1.2:8686/WebService/MyWebService.asmx" ; // my local or valid ip for webservice location 
    SoapObject request = new SoapObject(namespace, methodName); 

    // your webservice argument 
    String username = "your username"; 
    PropertyInfo usernameProp = new PropertyInfo(); 
    usernameProp.setName("username"); 
    usernameProp.setValue(username); 
    usernameProp.setType(String.class); 
    request.addProperty(usernameProp); 

    String pass = "your password"; 
    PropertyInfo passProp = new PropertyInfo(); 
    passProp.setName("password"); 
    passProp.setValue(pass); 
    passProp.setType(String.class); 
    request.addProperty(passProp); 

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
    envelope.dotNet = true; 
    envelope.setOutputSoapObject(request); 
    HttpTransportSE androidHttpTransport = new HttpTransportSE(url); 
    androidHttpTransport.call(soapAction, envelope); 
    SoapPrimitive response = (SoapPrimitive) envelope.getResponse(); 
    String json = response.toString(); 
    json = "{\"data\":" + json + "}"; 
    JSONObject mainJson = new JSONObject(json); 
    JSONArray jsonArray = mainJson.getJSONArray("data"); 
    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); 
    for (int i = 0; i < jsonArray.length(); i++) { 
     JSONObject objJson = jsonArray.getJSONObject(i); 
     HashMap<String , String> map = new HashMap(); 
     map.put("UserID" , objJson.getString("UserID")); 
     map.put("Username" , objJson.getString("Username")); 
     map.put("Token" , objJson.getString("Token")); 
     list.add(map) 
    } 

    //use your list 
0
JSONObject jsonObject = JSONParser.getObject(response); 

String title = JSONParser.getString(jsonObject, "UserID");  
String title = JSONParser.getString(jsonObject, "Username"); 
String title = JSONParser.getString(jsonObject, "Token"); 
相關問題