In this topic
Establishing a connection to ArcIMS
In the IMS namespace of the Web Application Developer Framework (ADF) connection library (ESRI.ArcGIS.ADF.Connection), the following classes can be used to establish a connection to ArcIMS:
- TCPConnection—Used to create a connection to an ArcIMS Application Server via TCP.
- HTTPConnection—Used to create a connection to ArcIMS via a Web server and the ArcIMS Servlet Connector.
Depending on the protocol used to connect to ArcIMS, various properties need to be set to initialize the connection. If connecting via HTTP, the Web server uniform resource locator (URL) is defined as a parameter of the HTTPConnection constructor, and ServiceName defines the ArcIMS service to which ArcXML requests will be sent.
If authentication is enabled on the Servlet Connector, the credentials can be provided via the User and Password properties on the connection object as shown in the following code example:
[C#]
HTTPConnection connection = new HTTPConnection("http://webservername");
connection.Port = 80;
connection.User = "private";
connection.Password = "pass.word";
connection.ServiceName = "MyServiceName";
- The Port property is optional (default is 80). Set it to the appropriate Web server port if it is different than the default. The Port property specifies the connector port on which the ArcIMS Application Server is listening for incoming requests.
- The URL provided to the HTTPConnection constructor can define the full path to the servlet connection. By default, it appends the servlet/com.esri.esrimap.Esrimap path onto the URL provided. If the Servlet Connector does not use the default path, define it in the URL.
- If connecting via TCP, the Host property defines the machine name or Internet protocol (IP) address of the machine on which the ArcIMS Application Server is running.
- The ServiceName property defines the ArcIMS service to which ArcXML requests will be sent. This process is shown in the following code example.
- User and Password do not apply to TCP connections.
TCPConnection connection = new TCPConnection();
connection.Host = "myserver";
connection.Port = 5300;
connection.ServiceName = "MyServiceName";
Obtaining a list of services
The TCPConnection and HTTPConnection classes derive from the IMSServerConnection abstract base class, which exposes the following methods to retrieve a list of services running on an ArcIMS server. Both return common .NET data types and can be iterated through to get a list of services.
- ClientServicesArray—Returns System.Collection.ArrayList.
- ClientServicesXml—Returns System.Xml.XmlDocument as shown in the following code example.
System.Collections.ArrayList arraylist = connection.ClientServicesArray();
IEnumerator arrayenum = arraylist.GetEnumerator();
while (arrayenum.MoveNext())
{
string servicename = (string)arrayenum.Current;
}
System.Xml.XmlDocument xmldocument = connection.ClientServicesXml();
System.Xml.XmlElement root = xmldocument.DocumentElement;
System.Xml.XmlNodeList nodelist = root.GetElementsByTagName("SERVICE");
foreach (System.Xml.XmlNode node in nodelist)
{
string servicename = node.Attributes["name"].InnerXml;
}