您的位置:首页 > 理论基础 > 计算机网络

HttpClient-调用webservice客户端

2015-06-27 15:23 621 查看
import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.HttpException;

import org.apache.commons.httpclient.methods.PostMethod;

public class TestClient {

private static class UTF8PostMethod extends PostMethod {

public UTF8PostMethod(String url) {

super(url);

}

@Override

public String getRequestCharSet() {

return "UTF-8";

}

}

public static void callActive() throws HttpException, IOException {

PostMethod method = new UTF8PostMethod(

"http://10.12.23.70:8080/service/active");

String params = "{tenant:'JINAN112',domain:'crm.qilu.com',admin:'holly_2011@126.com',password:'111aaa'}";

method.setParameter("action", params);

HttpClient httpClient = new HttpClient();

int code = httpClient.executeMethod(method);

System.out.println(method.getResponseBodyAsString());

System.out.println(code);

method.releaseConnection();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: