ورود

View Full Version : تحلیل یک کد جاوا



امیر وی بی
چهارشنبه 25 تیر 1393, 10:21 صبح
public static void main(String[] args) throws ClientProtocolException, IOException {
ArrayList<HashMap<String, String>>mylist = new ArrayList<HashMap<String, String>>();


//Get the data (see above)
HttpHost targetHost = new HttpHost("localhost", 8080, "http");
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials (newAuthScope(targetHost.getHostName(), targetHost.getPort()),newUsernamePasswordCredentia ls("test@liferay.com", "test"));
AuthCache authCache = new BasicAuthCache();
BasicScheme basicAuth = new BasicScheme();
authCache.put(targetHost, basicAuth);
BasicHttpContext ctx = new BasicHttpContext();
//ctx.setAttribute(ClientContext.AUTH_CACHE,authCach e);
HttpPost post = new HttpPost("/tunnel-web/secure/json");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("serviceClassName","com.liferay.portal.service.CountryServiceUtil"));
params.add(new BasicNameValuePair("serviceMethodName", "getCountries"));
params.add(new BasicNameValuePair("serviceParameters", "[]"));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
post.setEntity(entity);
HttpResponse resp = httpclient.execute(targetHost, post, ctx);
resp.getEntity().writeTo(System.out);
httpclient.getConnectionManager().shutdown();

}

}