arcims 两种连接方式(java connector,servlet connecto...

来源:百度文库 编辑:神马文学网 时间:2024/03/29 13:36:44
arcims 两种连接方式(java connector,servlet connector)的一些比较- -
(1) java connector主要是利用ims自封装的一些java类(ConnectionProxy,Map)来实现,通过api方法进行调用,
举例如下:
ConnectionProxy mapCon=new ConnectionProxy();
if(connectiontype.equalsIgnoreCase("http"))
{
mapCon.setConnectionType(ConnectionProxy.HTTP);
URL url = new URL(host);
mapCon.setUrl(url);
}
else if (connectiontype.equalsIgnoreCase("tcp"))
{
mapCon.setConnectionType(ConnectionProxy.TCP);
mapCon.setHost(host);
}
mapCon.setPort(port);
mapCon.setService(datasource);
mapCon.setDisplayMessages(true);
map=new Map();
map.initMap(mapCon,750,false,false,false,false);
map.setHeight(option.getHeight());
map.setWidth(option.getWidth());
.................
map.refresh();
String mapurl=map.getMapOutput().getURL();
String legendurl=map.getLegend().getLegendOutput().getURL();
在此过程中,Map对象的方法主要工作为构造arcxml request,并解析arcxml response
优点:基于api接口实现起来方便易用
缺点:解析map对象,影响速度。且调用map.refresh()方法,默认为做两次arcims request. 第一次为遍历axl的request,第二次为实际的request.
(2)servlet connector主要通过向servlet地址发送请求,然后获得返回的url流,得到响应
举例如下:
String serverUrl="http://localhost:8888/servlet/com.esri.esrimap.Esrimap?ServiceName=SantaClara";
URL imsURL =new URL(serverUrl);
URLConnection connection=imsURL.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
OutputStreamWriter out = new OutputStreamWriter(bos, "UTF8");
out.write(arcimsRequest, 0, arcimsRequest.length());
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF8"));
String ln;
String tempString=null;
while ((ln = in.readLine()) != null)
{
if (tempString == null)
{
tempString = ln;
}
else
{
tempString = tempString + ln;
}
}
arcxmlReponseStr = tempString.trim();
out.close();
in.close();
其中arcimsRequest格式如下:
Arcxml request:







//scalebar is set



















// scalebar is set






返回的arcxmlReponseStr ,格式如下:










通过xml parse解析即可得到输出url.
优点:向arcims应用服务器,只需请求arcxml request一次,只需调用自己的建构的arcimsrequest对象,此类对象为开源,可实现自优化
缺点:需要自己定义arcims request 对象,没有java connector简洁明了。
优化:可直接进行socket通信,通过tcp协议实现。