Opening the ArcIMS WMS Connector with Java
August 5th, 2008In order to WMS enable a map service in ArcIMS an operator must use the WMS connector manager, a user interface that’s a set of JSP pages. Users must manually select a service and navigate the menus for a service to become available via the WMS connector. However, there is a way to do this in Java.
If you’re working with the Java connector you can enable an ArcIMS service dynamically using the following JSP/Java code. This is accomplished using an applications server proxy to send commands via http post to your ArcIMS connector that will generate and seed the directories with the needed WMS capabilities data.
Here is your basic JSP page. Use request.getParameter() or session.getAttribute() or jsp:forward tags to manage the specific parameters such as add/delete and service name.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<%@ page language=”java” contentType=”text/html; charset=ISO-8859-1″ %>
<%@ page import=”java.util.*, java.io.*, java.net.*, com.esri.wms.*, com.esri.wms.Esrimap” session=”true” %>
<%@ taglib uri=”http://jakarta.apache.org/taglibs/i18n-1.0” prefix=”i18n” %>
<i18n:bundle id=”resBundle” baseName=”Res” debug=”false” />
<%
application.setAttribute(”resBundle”, resBundle);
// Initialize the Esrimap class without a redirect
String s = “”;
try {
URL u;
u = new URL(”http://<your server name>:8080/wmsconnector/com.esri.wms.Esrimap?request=capabilities&charset=ISO-8859-1″);
// Open the connection and prepare to POST
URLConnection uc = u.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true);
uc.setAllowUserInteraction(false);
DataOutputStream dstream = new DataOutputStream(uc.getOutputStream());
// The POST line
dstream.writeBytes(s);
dstream.close();
// Read Response
InputStream in = uc.getInputStream();
int x;
while ( (x = in.read()) != -1) {
System.out.write(x);
}
in.close();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuffer buf = new StringBuffer();
String line;
while ((line = r.readLine())!=null) {
buf.append(line);
}
} catch (IOException e) {
e.printStackTrace(); // should do real exception handling
}
boolean enabled;
String dStatus;
AdminCommand myAdm;
AppServerProxy myProx = new AppServerProxy(”<your server name>”, 5300);
myAdm = new AdminCommand(myProx, “<IMS Map Service name>”);
enabled = AdminCommand.checkCapabilitiesPresentOnDisk(”<IMS Map Service name>”);
if (!enabled)
dStatus = myAdm.updateCapabilitiesOnDisk(request, response, “wms”);
// Could also use deleteCapabilitiesOnDisk(request, response, “wms”);
%>
<HTML>
<HEAD>
<TITLE>HGL Dynamic WMS Startup</TITLE>
</HEAD>
<BODY>
First, put the JSP you want to use into the WMSCONNECTOR context. (unless you copy classes to your own context)<BR>
Second, initialize the class:<BR>
u = new URL(”http://<your server name>:8080/wmsconnector/com.esri.wms.Esrimap?request=capabilities&charset=ISO-8859-1″); <BR>
<BR>The initial parameters needed…<BR>
Missing mandatory REQUEST parameter. Possibilities are
{capabilities|GetCapabilities|map|GetMap|feature_info|GetFeatureInfo}
</BODY>
</HTML>
