httpput

时间:2022-09-27 19:35:56

String doHttpPut(String rpmName, String cookie) throws UnsupportedEncodingException, IOException, ClientProtocolException, Exception {
HttpPut httpPut = new HttpPut(postURI);

System.out.println("**********************");
httpPut.setHeader("Cookie", cookie);
httpPut.setHeader("Content-Type", "application/json;charset=UTF-8");
httpPut.setEntity(getParamaters(rpmName));

HttpResponse response = getHttpClient().execute(httpPut);
HttpEntity entity = response.getEntity();
String html = EntityUtils.toString(entity);
return html;
}

private StringEntity getParamaters(String rpmName) throws UnsupportedEncodingException {

String componentName = getComName(rpmName);

JSONObject parms = new JSONObject();

parms.put("ffff", componentName);

noChange(parms);

JSONObject subParams = new JSONObject();
subParams.put("ss", componentName);

parms.put("properties", subParams);

String jsonString = parms.toString();
System.out.println(jsonString);

return new StringEntity(jsonString, ContentType.APPLICATION_JSON);
}