|
@@ -1,6 +1,12 @@
|
|
|
package com.zskk.control;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+import java.io.OutputStreamWriter;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.URL;
|
|
|
+import java.net.URLConnection;
|
|
|
import java.security.KeyManagementException;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
import java.text.ParseException;
|
|
@@ -57,10 +63,11 @@ public class ViewController extends Controller {
|
|
|
* 在被连接数据库执行sql语句
|
|
|
*/
|
|
|
public void test() {
|
|
|
- Map<String, String> params = new HashMap<String, String>();
|
|
|
- params.put("studyuid", "1.2.840.1424321.23532.201804071725566372");
|
|
|
- String cotentString = doPost("http://10.84.138.254:8080/rest/getReportByStudyuid", params);
|
|
|
- renderText(cotentString);
|
|
|
+// Map<String, String> params = new HashMap<String, String>();
|
|
|
+// params.put("studyuid", "1.2.840.1424321.23532.201804071725566372");
|
|
|
+// String cotentString = doPost("http://10.84.138.254:8080/rest/getReportByStudyuid", params);
|
|
|
+// renderText(cotentString);
|
|
|
+ testPost("http://10.84.138.254:8080/rest/getReportByStudyuid");
|
|
|
}
|
|
|
|
|
|
public void executeSql2() {
|
|
@@ -181,4 +188,42 @@ public class ViewController extends Controller {
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
+ void testPost(String urlStr) {
|
|
|
+ try {
|
|
|
+ URL url = new URL(urlStr);
|
|
|
+ URLConnection con = url.openConnection();
|
|
|
+ con.setDoOutput(true);
|
|
|
+ con.setRequestProperty("Pragma:", "no-cache");
|
|
|
+ con.setRequestProperty("Cache-Control", "no-cache");
|
|
|
+ con.setRequestProperty("Content-Type", "text/xml");
|
|
|
+
|
|
|
+ OutputStreamWriter out = new OutputStreamWriter(con
|
|
|
+ .getOutputStream());
|
|
|
+ String xmlInfo = getXmlInfo();
|
|
|
+ System.out.println("urlStr=" + urlStr);
|
|
|
+ System.out.println("xmlInfo=" + xmlInfo);
|
|
|
+ out.write(new String(xmlInfo.getBytes("ISO-8859-1")));
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(con
|
|
|
+ .getInputStream()));
|
|
|
+ String line = "";
|
|
|
+ for (line = br.readLine(); line != null; line = br.readLine()) {
|
|
|
+ System.out.println(line);
|
|
|
+ }
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getXmlInfo() {
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append("<request>");
|
|
|
+ sb.append(" <studyuid>1.2.840.1424321.23532.201804071725566372</studyuid>");
|
|
|
+ sb.append("</request>");
|
|
|
+ return sb.toString();
|
|
|
+ }
|
|
|
+
|
|
|
}
|