Connecting to ArcGIS for Server with the SOM
Do the following steps:
- Set up an application with the Web Application Developer Framework (ADF) and ArcGIS for Server libraries using the sample description as a guide.
- Set the username, password, and domain variables to a user account in the agsuser or agsadmin groups on the SOM. Define the servername variable to be the machine on which the SOM is running.
- Set the serverobjectname to the name of an ArcGIS for Server map service.
See the following code example:
// Using the ArcGIS Connection library.
ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(userName, password,
domain);
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsServerConnection;
agsServerConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection
(serverName, identity);
agsServerConnection.Connect();
// Using the ArcGIS for Server API.
ESRI.ArcGIS.Server.IServerObjectManager serverObjectManager =
agsServerConnection.ServerObjectManager;
string serverType = "MapServer";
ESRI.ArcGIS.Server.IServerContext serverContext =
serverObjectManager.CreateServerContext(serverObjectName, serverType);
// If pooled, release context per request. If non-pooled, release context per session.
serverContext.ReleaseContext();
[VB.NET]
' Using the ArcGIS Connection library.
Dim identity As ESRI.ArcGIS.ADF.Identity = New ESRI.ArcGIS.ADF.Identity(userName, password, domain)
Dim agsServerConnection As ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection
agsServerConnection = New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(serverName, identity)
agsServerConnection.Connect()
' Using the ArcGIS for Server API.
Dim serverObjectManager As ESRI.ArcGIS.Server.IServerObjectManager = agsServerConnection.ServerObjectManager
Dim serverType As String = "MapServer"
Dim serverContext As ESRI.ArcGIS.Server.IServerContext = serverObjectManager.CreateServerContext(serverObjectName, serverType)
' If pooled, release context per request. If non-pooled, release context per session.
serverContext.ReleaseContext()