This sample assumes that a MapResourceManager and a Map (named Map1) are available in the current scope (for example, in the Page). The sample code references the default dataframe in the server object. Note that a MapLayerInfo and LayerDescription can be retrieved for each layer.
Local access to ArcGIS Server means connecting to a service via the SOM (Server Object Manager). The ArcGIS Server data source implementation in the Web ADF uses the ArcGIS Server SOAP API for both Local and Internet connections. As a result, the Web ADF uses the SOAP API to maintain state on the client by working with Value objects and service proxies instead of managing references to remote COM objects (as is the case in the single-source Web ADF included in ArcGIS Server 9.0/9.1). If the data source for a MapResource uses an ArcGIS Server Local connection, an ArcGIS Server Local MapResource class, named MapResourceLocal, provides access to server context. With access to server context, a developer can work with ArcObjects on the GIS Server. When working with ArcObjects via server context, you can change server object state and utilize fine-grained ArcObjects. Changing the state of a server object can be managed in two ways: deeply stateful and shallowly stateful. Deeply stateful changes should only be made when working with a non-pooled service. For non-pooled services there is a one-to-one relationship between client and server object, thus state can be maintained across requests within the same server object context. Shallowly stateful changes can be managed when when working with a pooled service. Clients working with a pool of server objects must create and release server context upon each request. As a result, state must be maintained on the client, applied to server context before an operation, then reset the server object before releasing server context. The Web ADF ArcGIS Server MapResource maintains state using ArcGIS Server SOAP Value objects included with the Web ADF (ESRI.ArcGIS.ADF.ArcGISServer). To manage state changes at the Web ADF level, update the properties of the MapDescription associated with a MapFunctionality or MapResource. See the topic Converting between data types in the Server SDK for under section Creating ArcGIS Server solutions > Developing Web applications using Web ADF > Working with graphics and core classes.
[C#]
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality gisFunctionality in
Map1.GetFunctionalities())
{
if (gisFunctionality is
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
{
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality
agsMapFunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
gisFunctionality;
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal
agsMapResourceLocal =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)
agsMapFunctionality.MapResource;
ESRI.ArcGIS.Server.IServerContext serverContext =
agsMapResourceLocal.ServerContextInfo.ServerContext;
ESRI.ArcGIS.Carto.IMapServer mapServer = (ESRI.ArcGIS.Carto.IMapServer)
serverContext.ServerObject;
ESRI.ArcGIS.Carto.IMapServerInfo mapServerInfo = mapServer.GetServerInfo
(mapServer.DefaultMapName);
ESRI.ArcGIS.Carto.IMapDescription mapDescription =
mapServerInfo.DefaultMapDescription;
ESRI.ArcGIS.Carto.IMapLayerInfos mapLayerInfos =
(ESRI.ArcGIS.Carto.IMapLayerInfos)mapServerInfo.MapLayerInfos;
for (int i = 0; i < mapLayerInfos.Count; i++)
{
ESRI.ArcGIS.Carto.IMapLayerInfo mapLayerInfo =
(ESRI.ArcGIS.Carto.IMapLayerInfo)mapLayerInfos.get_Element(i);
ESRI.ArcGIS.Carto.ILayerDescription layerDescription =
(ESRI.ArcGIS.Carto.ILayerDescription)
mapDescription.LayerDescriptions.get_Element(i);
}
}
}
[VB.NET]
For Each gisFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IGISFunctionality In Map1.GetFunctionalities()
If TypeOf gisFunctionality Is ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality Then
Dim agsMapFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality = CType(gisFunctionality, ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
Dim agsMapResourceLocal As ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal = CType(agsMapFunctionality.MapResource, ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)
Dim serverContext As ESRI.ArcGIS.Server.IServerContext = agsMapResourceLocal.ServerContextInfo.ServerContext
Dim mapServer As ESRI.ArcGIS.Carto.IMapServer = CType(serverContext.ServerObject, ESRI.ArcGIS.Carto.IMapServer)
Dim mapServerInfo As ESRI.ArcGIS.Carto.IMapServerInfo = mapServer.GetServerInfo(mapServer.DefaultMapName)
Dim mapDescription As ESRI.ArcGIS.Carto.IMapDescription = mapServerInfo.DefaultMapDescription
Dim mapLayerInfos As ESRI.ArcGIS.Carto.IMapLayerInfos = CType(mapServerInfo.MapLayerInfos, ESRI.ArcGIS.Carto.IMapLayerInfos)
Dim i As Integer = 0
Do While i < mapLayerInfos.Count
Dim mapLayerInfo As ESRI.ArcGIS.Carto.IMapLayerInfo = CType(mapLayerInfos.get_Element(i), ESRI.ArcGIS.Carto.IMapLayerInfo)
Dim layerDescription As ESRI.ArcGIS.Carto.ILayerDescription = CType(mapDescription.LayerDescriptions.get_Element(i), ESRI.ArcGIS.Carto.ILayerDescription)
i + = 1
Loop
End If
Next gisFunctionality