2016-10-04 4 views
-11

finden Sie unter URLWas der Code in Android Studio ist

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

Dies wird wie unten, um ein JSON-Objekt zurück.

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

Was den Code wird eine Antwort

+1

Ich wähle diese Frage als Wegthema schließen weil dies kein Ort ist, an dem Leute aufgefordert werden, Code zu schreiben. – AndroidMechanic

+0

was hast du bisher versucht. https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=android%20http%20get%20with%20parameters Link wird Ihnen helfen – Anjali

Antwort

0

zu erhalten, wenn Sie SOAP verwenden, wie dies tun etw:

 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"); 
Verwandte Themen