Citrix API 成功调用案例, 如有疑问请联系 QQ 232600624
package cn.ccvnc.http.service;
import io.lions.http.client.ResultEntity;
import io.lions.http.client.Transfer;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
/**
*
* @author ccvnc
*
*/
public class Citrix {
static BasicCookieStore cookieStore = null;
static CloseableHttpClient httpClient = null;
static Map<String, String> cookieMap = new HashMap<String, String>();
static HttpClientContext context = null;
private String host;
private int port = 80;
public Map<String, String> basicHeaders() {
String h = host;
if (port > -1 && port != 80) {
h += ":" + port;
}
Map<String, String> headers = new HashMap<String, String>();
headers.put("Host", host);
headers.put("Accept", "application/xml, text/xml, */*; q=0.01");
headers.put("Accept-Language", "en-us,en;q=0.7,fr;q=0.3");
headers.put("Accept-Encoding", "gzip, deflate");
headers.put("X-Requested-With", "XMLHttpRequest");
headers.put("X-Citrix-IsUsingHTTPS", "No");
if (cookieMap != null) {
headers.put("Csrf-Token", cookieMap.get("CsrfToken"));
}
headers.put("Referer", "http://" + h + "/Citrix/StoreWeb/");
headers.put("Connection", "keep-alive");
headers.put("Pragma", "no-cache");
headers.put("Cache-Control", "no-cache");
return headers;
}
public void context() {
context = HttpClientContext.create();
}
// 1. /Home/Configuration
public ResultEntity homeConfiguration() throws MalformedURLException {
URL url = Transfer.g