How to connect to an ArcGIS for Server Web service


Summary
This topic shows how to connect to an ArcGIS for Server Web service. The ArcGIS for Server Simple Object Access Protocol (SOAP) application programming interface (API) can be used to interact with a Web service directly via its MapDescription and LayerDescription. Each service type (for example, map service) maintains its own proxy class that serializes SOAP requests to and deserializes SOAP responses from an ArcGIS for Server Web service. Client-side Value objects, such as MapDescription and LayerDescription, store values that are used by the proxy during the serialization process. Developers often interact with the Value objects to construct a SOAP request and call methods on the proxy to send the request. Value objects offer the benefit of working with classes in a native client-side development environment that manage interaction with SOAP strings. Otherwise, a developer would be required to manage (create, append, parse) SOAP, which can be a labor intensive task.

Connecting to an ArcGIS for Server Web service

This topic shows how to connect to an ArcGIS for Server Web Service endpoint using pre-created Value objects and a proxy class included with the Web Application Developer Framework (ADF). Since the Web Service Description Language (WSDL) for an ArcGIS for Server service type is always the same, the Value objects and proxy class in the Web ADF can be used to connect to any ArcGIS for Server Web Service endpoint of the same type (for example, MapServer). You can also generate your client-side Value objects and proxy classes by using a SOAP toolkit.

The endpoint for an ArcGIS for Server Web service takes the form of service_name/service_type. In the following code example, "MapServer" is the service_type. There might also be a folder containing one or more services under service_type. In that situation, the endpoint takes the form, folder_name/service_name/service_type. Folders can be created in ArcCatalog and Manager.
Do the following steps:
  1. Set up a Web application with the Web ADF assembly.
  2. Edit the endpoint variable and change the "servicename" to a valid service name.
  3. Edit the value for the MapServerProxy constructor to include a valid Web server name and path to ArcGIS for Server Web service endpoints.
[C#]
string serverName = "localhost";
string instance = "arcgis/services";

// Using the ADF Common API data source implementation of the ArcGIS for Server Web Service API.
string serviceNameAndType = "MapFusedCache/MapServer";

ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy agsSoapMapServerProxy = new
    ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy("http://" + serverName + "/" +
    instance + "/" + serviceNameAndType);

ESRI.ArcGIS.ADF.ArcGISServer.MapServerInfo agsSoapMapServerInfo =
    agsSoapMapServerProxy.GetServerInfo(agsSoapMapServerProxy.GetDefaultMapName());

ESRI.ArcGIS.ADF.ArcGISServer.MapDescription agsSoapMapDescription =
    agsSoapMapServerInfo.DefaultMapDescription;
[VB.NET]
Dim serverName As String = "localhost"
Dim instance As String = "arcgis/services"

' Using the ADF Common API data source implementation of the ArcGIS for Server Web Service API.
Dim serviceNameAndType As String = "MapFusedCache/MapServer"

Dim agsSoapMapServerProxy As ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy = New ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy("http://" & serverName & "/" & instance & "/" & serviceNameAndType)

Dim agsSoapMapServerInfo As ESRI.ArcGIS.ADF.ArcGISServer.MapServerInfo = agsSoapMapServerProxy.GetServerInfo(agsSoapMapServerProxy.GetDefaultMapName())

Dim agsSoapMapDescription As ESRI.ArcGIS.ADF.ArcGISServer.MapDescription = agsSoapMapServerInfo.DefaultMapDescription






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
  • ESRI.ArcGIS.ADF.ArcGISServer