包含url参数的Android Call XML Web Service

时间:2014-08-08 09:10:31

标签: android android-webservice

我正在尝试使用包含webservice参数的get方法调用webservice。但我无法在互联网上找到答案,任何人都可以帮助我。我在下面给出了web服务

http://api.crmseries.com/user/ValidateUser?email=don@crmSerssies.com&password=visi

2 个答案:

答案 0 :(得分:1)

这应该有效!

public void postData() {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://api.crmseries.com/user/ValidateUser");

try {
    // Add your data
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("email", "don@crmSerssies.com"));
    nameValuePairs.add(new BasicNameValuePair("password", "visi"));
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

    // Execute HTTP Post Request
    HttpResponse response = httpclient.execute(httppost);

} catch (ClientProtocolException e) {
    // TODO Auto-generated catch block
} catch (IOException e) {
    // TODO Auto-generated catch block
}
}

答案 1 :(得分:0)

这应该更好:)

public void getData(String mEmail, String mPwd) {
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpgett = new HttpGet("http://api.crmseries.com/user/ValidateUser?email=" + mEmail + "&password=" + mPwd);

    try {


        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httpget);

    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
    } catch (IOException e) {
        // TODO Auto-generated catch block
    }
    }