Search in sources :

Example 1 with Response

use of com.ctrip.platform.dal.daogen.entity.Response in project dal by ctripcorp.

the class WebUtil method getAllInOneResponse.

public static Response getAllInOneResponse(String keyname, String environment) throws Exception {
    Response res = null;
    if (keyname == null || keyname.isEmpty())
        return res;
    if (SERVICE_RUL == null || SERVICE_RUL.isEmpty())
        return res;
    if (APP_ID == null || APP_ID.isEmpty())
        return res;
    try {
        URIBuilder builder = new URIBuilder(SERVICE_RUL).addParameter("ids", keyname).addParameter("appid", APP_ID);
        if (environment != null && !environment.isEmpty())
            builder.addParameter("envt", environment);
        URI uri = builder.build();
        HttpClient sslClient = initWeakSSLClient();
        if (sslClient != null) {
            HttpGet httpGet = new HttpGet();
            httpGet.setURI(uri);
            HttpResponse response = sslClient.execute(httpGet);
            HttpEntity entity = response.getEntity();
            String content = EntityUtils.toString(entity);
            res = JSON.parseObject(content, Response.class);
        }
        return res;
    } catch (Throwable e) {
        throw e;
    }
}
Also used : Response(com.ctrip.platform.dal.daogen.entity.Response) HttpResponse(org.apache.http.HttpResponse) HttpEntity(org.apache.http.HttpEntity) HttpClient(org.apache.http.client.HttpClient) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

Response (com.ctrip.platform.dal.daogen.entity.Response)1 URI (java.net.URI)1 HttpEntity (org.apache.http.HttpEntity)1 HttpResponse (org.apache.http.HttpResponse)1 HttpClient (org.apache.http.client.HttpClient)1 HttpGet (org.apache.http.client.methods.HttpGet)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1