JAvaコール(リクエスト)リモートサービスアドレス
Javaサンプルコードは次のとおりです.
/**
* Ajax
* @author jiyanle
* @date 2014-10-31
*/
public String getPosition() {
HttpServletResponse response = ServletActionContext.getResponse();
String jsonStr = "";
PrintWriter out = null;
BufferedReader in = null;
try {
String param = "compNo=341421110525083290®ionCode=340000";
URL url = new URL("
http://gis.wsjd.gov.cn:8080/Weisheng/placeinfo/getPlacesAction.action?"+param
);
URLConnection conn = url.openConnection();
conn.setUseCaches(true);
// POST ;
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestProperty("Content-type", "application/octest-stream");
// URLConnection
out = new PrintWriter(conn.getOutputStream());
//
out.print(param);
//flush
out.flush();
// BufferedReader URL
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
jsonStr = in.readLine();
//ajax
out = response.getWriter();
out.print(jsonStr);
}
catch (Exception e) {
e.printStackTrace();
}
// finally 、
finally {
try {
if (out != null)
{
out.close();
}
if (in != null)
{
in.close();
}
}catch (Exception e) {
e.printStackTrace();
}
}
return null;
}