HOW TO
This article describes the necessary steps required to create an ArcIMS service using the Java Connector. The code described below does not require Map Configuration file to create the service. The map configuration information is provided in String format instead.
Code:
cp.setHost("IMSHost");
cp.setPort(5300);
cp.setConnectionType(cp.TCP_ADMIN);
cp.setUsername("admin");
cp.setPassword("admin");
Note:
IMSHost and port are hostname and port number respectively for ArcIMS Application Server. The user-name and password are same as those for ArcIMS Administrator.
Code:
VirtualServerCollection vsCollection = VirtualServerCollection.getVirtualServers(cp);
VirtualServer v = null;
boolean imageServerAvailable=false;
for(int i=0;i<vsCollection.size();i++) {
v = vsCollection.getVirtualServer(i);
if (v.getName().equals("ImageServer1")){
imageServerAvailable = true;
break;
}
}
Code:
if (imageServerAvailable){
Service service = new Service();
service.setName("mapServiceName");
service.setOutputCleanup(20);
service.setOutputDir("C:/ArcIMS/output");
service.setOutputURL("http://webserver/output");
service.setPixelCount(1048576);
service.setImageType(Service.IMAGE_JPG);
service.setVirtualServer(v.getName(),v.getType(),v.getVersion());
Code:
StringBuffer sb = new StringBuffer();
sb.append("<MAP> <PROPERTIES>");
sb.append("<ENVIRONMENT>");
sb.append("<LOCALE country=\"US\" language=\"en\" variant=\"\" />");
sb.append("<UIFONT color=\"0,0,0\" name=\"dialog\" size=\"12\" style=\"regular\" />");
sb.append("<SCREEN dpi=\"96\" />");
sb.append("</ENVIRONMENT>");
sb.append("<ENVELOPE minx=\"-178.2\" miny=\"18.9\" ");
sb.append("maxx=\"-66.9\" maxy=\"71.4\" name=\"Initial_Extent\" />");
sb.append("<MAPUNITS units=\"decimal_degrees\" /></PROPERTIES>");
sb.append("<WORKSPACES>");
sb.append("<SHAPEWORKSPACE name=\"shp_ws-0\" directory=\"C:\\ESRI\\ESRIDATA\\USA\" />");
sb.append("</WORKSPACES>");
sb.append("<LAYER type=\"featureclass\" name=\"states\" visible=\"true\" id=\"1\">");
sb.append("<DATASET name=\"states\" type=\"polygon\" workspace=\"shp_ws-0\" />");
sb.append("<SIMPLERENDERER>");
sb.append("<SIMPLEPOLYGONSYMBOL boundarytransparency=\"1.0\" filltransparency=\"1.0\" ");
sb.append("fillcolor=\"27,27,227\" boundarycaptype=\"round\" />");
sb.append("</SIMPLERENDERER></LAYER>");
sb.append("</MAP>");
String configInfo = sb.toString();
Code:
service.setConfigFile("");
service.setConfigContents(configInfo);
Code:
service.addService(cp);
service.startService(cp);
}
Article ID:000005635
Get help from ArcGIS experts
Download the Esri Support App