// 实例化主机名验证接口
HttpsURLConnection.setDefaultHostnameVerifier(new MyHostnameVerifier());
HttpsURLConnection urlCon = null;
Map<String, String> returnMap =null;
try {
urlCon.setReadTimeout(60000);
urlCon.setDoInput(true);
urlCon.setDoOutput(true);
urlCon.setRequestMethod("POST");
urlCon.setRequestProperty("Content-Type", "text/xml; charset=GBK");
urlCon.setRequestProperty("Content-Length", String.valueOf(xmlStr.getBytes("GBK").length));
urlCon.setRequestProperty("Accept-Charset", "GBK");
urlCon.getOutputStream().flush();
SAXReader saxReader = new SAXReader();
returnMap = this.parseXML(root, new HashMap<String, String>());
doc.setXMLEncoding("GBK");
String resultXml = doc.asXML();
returnMap.put("resultXml",resultXml);
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
HttpsURLConnection.setDefaultHostnameVerifier(new MyHostnameVerifier());
HttpsURLConnection urlCon = null;
Map<String, String> returnMap =null;
try {
urlCon = (HttpsURLConnection) (new URL(httpsUrl)).openConnection();
urlCon.setSSLSocketFactory(HttpsPost.initHttpsURLConnection(password, keyStorePath, trustStorePath));
urlCon.setConnectTimeout(60000);urlCon.setReadTimeout(60000);
urlCon.setDoInput(true);
urlCon.setDoOutput(true);
urlCon.setRequestMethod("POST");
urlCon.setRequestProperty("Content-Type", "text/xml; charset=GBK");
urlCon.setRequestProperty("Content-Length", String.valueOf(xmlStr.getBytes("GBK").length));
urlCon.setRequestProperty("Accept-Charset", "GBK");
urlCon.setUseCaches(false);
//urlCon.getOutputStream() : Returns an output stream that writes to this connection.
urlCon.getOutputStream().write(xmlStr.getBytes("GBK"));urlCon.getOutputStream().flush();
urlCon.getOutputStream().close();
//urlCon.getInputStream() :Returns an input stream that reads from this open connection.
BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream(),"GBK"));SAXReader saxReader = new SAXReader();
Document doc = saxReader.read(in, "GBK");
returnMap = this.parseXML(root, new HashMap<String, String>());
doc.setXMLEncoding("GBK");
String resultXml = doc.asXML();
returnMap.put("resultXml",resultXml);
return returnMap;
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}