1

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

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

4

2 回答 2

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
}
}
于 2014-08-08T09:14:43.813 回答
0

This should be better :)

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
    }
    }
于 2014-08-08T09:42:30.510 回答