In this topic
In the IMS namespace of the Web Application Developer Framework (ADF) connection library (ESRI.ArcGIS.ADF.Connection), two classes can be used to establish a connection to ArcIMS: TCPConnection and HTTPConnection. The TCPConnection class is used to create a connection to an ArcIMS application server via TCP. The HTTPConnection class is 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, a number of 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:
[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; the default is port 80. Set it to the appropriate Web server port if it is different than the default. 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 IP address of the machine on which the ArcIMS application server is running. The Port property specifies the connector port on which the ArcIMS application server is listening for incoming requests. The ServiceName property defines the ArcIMS service to which ArcXML requests will be sent. This process is shown in the following code. User and Password do not apply to TCP connections.
[C#]
TCPConnection connection = new TCPConnection();
connection.Host = "myserver";
connection.Port = 5300;
connection.ServiceName = "MyServiceName";
Both the TCPConnection and HTTPConnection classes derive from the IMSServerConnection abstract base class, which exposes two methods to retrieve a list of services running on an ArcIMS server: ClientServicesArray and ClientServicesXml. Both return common .NET data types. ClientServicesArray returns System.Collection.ArrayList and ClientServicesXml returns System.Xml.XmlDocument as shown in the following code. Both can be iterated through to get a list of services.
[C#]
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;
}