Send ArcXML using ArcIMS Java Connector API

Here is a code sample to send raw ArcXML strings to ArcIMS Server using the Java Connector API

Using TCP connection

//Create new instance of connectionproxy
//Package - com.esri.aims.mtier.io.ConnectionProxy
ConnectionProxy cp = new ConnectionProxy();

//Name of the machine where ArcIMS Application server is running
cp.setHost("imstest1");

//Set the port (5300 is the default)
cp.setPort(5300);

//Set the connection type to TCP
cp.setConnection(ConnectionProxy.TCP)
// or cp.setConnectionType("TCP");

//set the name of the map service
cp.setService("NorthAmerica");

//set this to true if you need the ArcXML to be shown in the console
cp.setDisplayMessages(false);

//Construct the ArcXML request, in this sample shown a GET_SERVICE_INFO request is sent
String myrequest = "<ARCXML version="1.1"><REQUEST><GET_SERVICE_INFO renderer="false" extensions="false" fields="false" envelope="false" /></REQUEST></ARCXML>";

//create a placeholder for the ArcXML response
String myresponse;

//Send the request to the server
//Remember that the response is string representation of ArcXML
myresponse = cp.send(myrequest);

Using HTTP connection

The same code as above except for the fact that we are using the HTTP connection scheme. In this case we are talking to the
ArcIMS servlet connector.

//Create new instance of connectionproxy
//Package - com.esri.aims.mtier.io.ConnectionProxy
ConnectionProxy cp = new ConnectionProxy();

//Set the URL to point to the machine where the ArcIMS Servlet Connector is installed
cp.setUrl(new java.net.URL("http://myarcimserver"));

//Set the connection type to HTTP
cp.setConnectionType("HTTP");
// or cp.setConnection(ConnectionProxy.HTTP)

//Set the service name
cp.setService("NorthAmerica");

//Set this to ture if you need ArcXML to be displayed in the console
cp.setDisplayMessages(false);

//Construct the ArcXML request
String myrequest = "<ARCXML version="1.1"><REQUEST><GET_SERVICE_INFO renderer="false" extensions="false" fields="false" envelope="false" /></REQUEST></ARCXML>";

//Send the request to the server
//Remember that the response is string representation of ArcXML
String myresponse = cp.send(myrequest);

Note: You will have to escape the double quotes inside the ArcXML request before sending. Here is an example

String myrequest = “<ARCXML version=\”1.1\”>….</ARCXML>”;