GeoData services


Local (DCOM) connections are only supported for ArcGIS Server versions prior to 10.1.

About the geodatabase

The cornerstone of a geographic information system (GIS) application is geographic information represented as GIS datasets. ArcGIS for Server for .NET can host and manage GIS data in geodatabases. A geodatabase (short for geographic database) is the core geographic information model used to organize GIS data into thematic layers and spatial representations.
The geodatabase is built on standard relational database technology, incorporating ArcSDE as the gateway to the underlying database management system (DBMS). ArcGIS supports the following DBMSs:
  • IBM DB2
  • Informix
  • Oracle
  • SQL Server
Geodatabase storage includes the schema and rule base for each geographic dataset as well as simple, tabular storage of the spatial and attribute data.
The geodatabase schema includes the definitions, integrity rules, and behavior for each geographic dataset. These include properties for feature classes, topologies, networks, raster catalogs, terrains, relationships, domains, and so on. The schema is persisted in a collection of geodatabase metatables in the DBMS that defines the integrity and behavior of the geographic information. The spatial representations are most commonly stored as vector features or as raster datasets with traditional tabular attributes.

Versioning

The geodatabase supports long transactions. Unlike standard database transactions, a long transaction spans a long period of time, from minutes to hours, up to days or months. Examples of a long transaction include creating a subdivision in a parcel database or fixing a collection of topology errors in a dataset.
To support the long transaction requirements of GIS users, the geodatabase extends the standard DBMS transaction model by allowing multiple concurrent states of the databases to coexist. This is referred to as a multiversioned view of the database or versioning. Versioning extends the basic DBMS transaction model by supporting long units of work (held within a version) that can span multiple connections to the database and extend over a period of weeks or months.
Each version can be used to represent ongoing work, such as a design or plan. Individual datasets in a geodatabase can be versioned. Versioned datasets support editing using an optimistic model that does not acquire locks. Versioning a dataset also allows it to participate in extended transactional workflows including history, disconnected editing, and versioned data replication.

GeodataServer object

To exploit geodatabases and their contents through ArcGIS for Server applications, ArcGIS for Server includes a GeodataServer server object that provides access to the versions, replicas, and datasets in a geodatabase. You can use a geodata server in a number of scenarios including the following:
  • Creating and synchronizing replicas—The geodata server has methods for creating replicas and for synchronizing the geodatabase with one of its replicas. You can use this capability to create server applications that periodically synchronize a geodatabase with its replicas on a pre-defined schedule. All the logic to copy data changes and incorporate them runs in the GIS server. This can all be orchestrated using Web services.
  • Extracting and uploading data—The geodata server includes methods for extracting data as geodatabase Extensible Markup Language (XML), file geodatabase, or personal geodatabase. The extracted data can be based on attribute or spatial queries. The geodata server also supports methods for uploading data into the geodatabase. You can use these capabilities to create applications and Web services for distributing data to remote editing clients and to incorporate their changes into the geodatabase.
  • Geoprocessing dataset sources—The geodata server can be queried for its datasets as data elements that can be used as inputs to geoprocessing functions.
  • Querying data—The geodata server provides methods for executing attribute and spatial queries that are returned as application configurable chunks of records.
  • Pooling database connections—The geodata server is a connection to a geodatabase workspace. You can get the connected workspace from the geodata server. Applications can use this capability to make fine-grained ArcObjects calls against the workspace. This capability can also be used as a mechanism for pooling database connections.
Use ArcCatalog to create a geodata server object by specifying the geodatabase connection information and other properties of the server object.
The geodatabase query and management objects reside in the esriGeodatabase and esriGeodatabaseDistributed libraries. GeodataServer resides in the esriGeodatabaseDistributed library, but you will typically work with objects in these libraries with objects in a number of other libraries within your application.
GeodataServer is a ServerObject, served by ArcGIS Server, that can be used to discover the datasets, versions, and replicas in a geodatabase and to query, extract, and replicate data between geodatabases. Internally, GeodataServer is a connection to a geodatabase that exposes the high-level functionality of the geodatabase using the IGeodataServer interface. The coarse-grained functionality of GeodataServer can be accessed through the IGeodataServer interface.
The following code example shows how to get a reference to a geodata server named calgarydb:
[C#]
IServerContext ctx = som.CreateServerContext("calgarydb", "GeoDataServer");
IGeoDataServer gs = ctx.ServerObject as IGeoDataServer;
[VB.NET]
Dim ctx As IServerContext = som.CreateServerContext("calgarydb", "GeoDataServer")
Dim gs As IGeoDataServer = ctx.ServerObject
The GeodataServer object supports the IGeodataServerObjects interface. This interface can be used by accessing a geodata server over Distributed Component Object Model (DCOM) to get a reference to its geodatabase connection as a workspace object. Using this workspace object, applications can make fine-grained ArcObjects calls against the workspace. This also allows the geodata server to be used to pool and serve geodatabase connections. The following code example shows how to use IGeodataServerObjects to get a reference to the workspace and compress it:
[C#]
IGeoDataServerObjects gsobj = gs as IGeoDataServerObjects;
IWorkspace ws = gsobj.DefaultWorkingWorkspace;

IVersionedWorkspace vws = ws as IVersionedWorkspace;
vws.Compress();
[VB.NET]
Dim gsobj As IGeoDataServerObjects = gs
Dim ws As IWorkspace = gsobj.DefaultWorkingWorkspace

Dim vws As IVersionedWorkspace = ws
vws.Compress()
The GeodataServer can be used as follows:
  • Stateless (pooled) manner—When used in a pooled manner, the current database state of the working version is automatically refreshed by ArcGIS Server each time an instance of GeodataServer in the pool is handed out to an application through a call to CreateServerContext.
  • Stateful (non-pooled) manner—When used in a non-pooled manner, the application is responsible for refreshing the database state associated with the working version as needed.
The following code example shows how to get a reference to the geodata server workspace and refresh its version:
[C#]
IGeoDataServerObjects gsobj = gs as IGeoDataServerObjects;
IWorkspace ws = gsobj.DefaultWorkingWorkspace;

IVersion ver = ws as IVersion;
ver.RefreshVersion();
[VB.NET]
Dim gsobj As IGeoDataServerObjects = gs
Dim ws As IWorkspace = gsobj.DefaultWorkingWorkspace

Dim ver As IVersion = ws
ver.RefreshVersion()
Server applications can run geoprocessing tools in the ServerContext holding a GeodataServer object and use the geodata server object to get input data elements from the workspace.

GeodataServer functions

This section describes the key functions of the GeodataServer that are accessible by the IGeodataServer interface.

Listing datasets

The get_DataElements method returns information on the data elements for all datasets in the workspace. DataElements are lightweight objects that describe datasets that can be used in geoprocessing functions. Examples of such classes are DEFolder, DETable, and DEShapeFile. These objects are simple structures whose properties describe the dataset. For example, DEShapeFile has properties, such as Extent and SpatialReference. A subset of the data elements describes geodatabase datasets. Classes, such as DEFeatureClass and DEFeatureDataset can be used to describe geodatabase datasets.
Every DataElement supports the IGPValue interface, allowing DataElements to be used directly as input to the Validate and Execute methods of the function.
Applications can request full or partial information (name and type only). Information on the DataElements set in the workspace is cached by GeodataServer on start up. Administrators can control the frequency with which this information is refreshed. The catalog path for a data element is based on the concatenation of the catalog path of the geodata server with the path of the dataset in the database. Data elements retrieved from a geodata server can be used as arguments to geoprocessing tools running in the same server context as the geodata server.
The following code example shows how to get the data elements for a geodata server and print their names and types to a list box control, where gs is a reference to the geodata server and ctx is a reference to its server context:
[C#]
IDEBrowseOptions deb = ctx.CreateObject("esriGeodatabase.DEBrowseOptions")as
    IDEBrowseOptions;
deb.ExpandType = esriDEExpandType.esriDEExpandChildren;
deb.RetrieveFullProperties = true;
deb.RetrieveMetadata = false;

IDataElements des = gs.get_DataElements(deb);
IDataElement de;
for (int i = 0; i < des.Count; i++)
{
    de = des.get_Element(i);
    ListBox1.Items.Add(de.Name + " (" + de.Type + ")");
}
[VB.NET]
Dim deb As IDEBrowseOptions = ctx.CreateObject("esriGeodatabase.DEBrowseOptions")
deb.ExpandType = esriDEExpandType.esriDEExpandChildren
deb.RetrieveFullProperties = True
deb.RetrieveMetadata = False

Dim des As IDataElements = gs.DataElements(deb)
Dim de As IDataElement

Dim i As Integer
For i = 0 To des.Count - 1
    de = des.Element(i)
    ListBox1.Items.Add(de.Name & " (" & de.Type & ")")
Next

Listing versions

The get_Versions method returns information on the versions in the geodatabase. This method returns an array of GPVersionInfos. Each GPVersionInfo object includes its name, its parent version name, its ancestor and child versions' names, the dates when it was created and last modified, and access permissions.
The following code example shows how to get the versions for a geodata server and print their names to a list box control, where gs is a reference to the geodata server:
[C#]
IGPVersionInfos vinfos = gs.get_Versions();
IGPVersionInfo vinfo;
for (int i = 0; i < vinfos.Count; i++)
{
    vinfo = vinfos.get_Element(i);
    ListBox1.Items.Add(vinfo.VersionName);
}
[VB.NET]
Dim vinfos As IGPVersionInfos = gs.Versions
Dim vinfo As IGPVersionInfo
Dim i As Integer

For i = 0 To vinfos.Count - 1
    vinfo = vinfos.Element(i)
    ListBox1.Items.Add(vinfo.VersionName)
Next

Listing replicas

The get_Replicas method returns information on replicas in a geodatabase. This method returns an array of GPReplicas. GPReplica includes information, such as the replicated datasets, date it was created, date it was last synchronized, as well as information about the sibling geodatabase.
The following code example shows how to get all the replicas for a geodata server and print their names to a list box control, where gs is a reference to the geodata server:
[C#]
IGPReplicas reps = gs.get_Replicas();
IGPReplica rep;
for (int i = 0; i < reps.Count; i++)
{
    rep = reps.get_Element(i);
    ListBox1.Items.Add(rep.Name);
}
[VB.NET]
Dim reps As IGPReplicas = gs.Replicas
Dim rep As IGPReplica

Dim i As Integer
For i = 0 To reps.Count - 1
    rep = reps.Element(i)
    ListBox1.Items.Add(rep.Name)
Next

Querying data

Applications can use the TableSearch method to query tables and feature classes that are being served. Both attribute and spatial queries can be performed. The results of a query are returned in user-specified chunks. Applications can control the size of the chunk. The results for each chunk are returned as a recordset containing chunk size records. Only datasets that are accessible by the database user associated with the geodata server connection can be queried. See the following code example:
[C#]
IServerContext ctx = som.CreateServerContext("calgarydb", "GeoDataServer");
IGeoDataServer gs = ctx.ServerObject as IGeoDataServer;

IQueryFilter qf = ctx.CreateObject("esriGeodatabase.QueryFilter")as IQueryFilter;
qf.WhereClause = "Shape.Area > 10000";
IResultPortionInfo range = ctx.CreateObject("esriGeodatabase.ResultPortionInfo")as
    IResultPortionInfo;
range.StartIndex = 0;
//Set the query to retrieve the result in chunks 1/10th of the maximum allowed by the GeoDataServer.
range.Count = (gs.MaxRecordCount / 10);

IGDSQueryResultPortion resPortion = gs.TableSearch(gs.DefaultWorkingVersion, 
    "parcels", qf, range);
IRecordSet recs = resPortion.Records;
ICursor cursor = recs.Cursor(true);
IRow row;
while ((row = cursor.NextRow()) != null)
{
    // Do something with the row.
}

ctx.ReleaseContext();
[VB.NET]
Dim ctx As IServerContext = som.CreateServerContext("calgarydb", "GeoDataServer")
Dim gs As IGeoDataServer = ctx.ServerObject

Dim qf As IQueryFilter = ctx.CreateObject("esriGeodatabase.QueryFilter")
qf.WhereClause = "Shape.Area > 10000"
Dim range As IResultPortionInfo = ctx.CreateObject("esriGeodatabase.ResultPortionInfo") As IResultPortionInfo
range.StartIndex = 0
'Set the query to retrieve the result in chunks 1/10th of the maximum allowed by the GeoDataServer.
range.Count = (gs.MaxRecordCount / 10)

Dim resPortion As IGDSQueryResultPortion = gs.TableSearch(gs.DefaultWorkingVersion, "parcels", qf, range)
Dim recs As IRecordSet = resPortion.Records
Dim cursor As ICursor = recs.Cursor(True)
Dim row As IRow = cursor.NextRow()
While Not row Is Nothing
    ' Do something with the row.
    row = cursor.NextRow()
End While
ctx.ReleaseContext()

Importing and uploading data

The ImportXMLWorkspaceDocument method can be used to upload data to the geodata server. An application can perform local data extraction to XML, then upload the resulting document to the server. All data element types are supported. The result of the import is the creation of datasets. The created datasets are owned by the database user associated with the geodata server.
The following code example shows how to use the ImportXMLWorkspaceDocument method to import an XML document that has been uploaded by the user of a Web application, where gs is a reference to the geodata server, ctx is a reference to its server context, and fileUpload is the name of a file upload Hypertext Markup Language (HTML) control:
[C#]
HttpPostedFile myFile = fileUpload.PostedFile;
int nFileLen = myFile.ContentLength;

byte[] myData = new Byte[nFileLen];
myFile.InputStream.Read(myData, 0, nFileLen);

IGDSData gdata = ctx.CreateObject("esriGeodatabaseDistributed.GDSData")as IGDSData;
gdata.TransportType = esriGDSTransportType.esriGDSTransportTypeEmbedded;
gdata.set_EmbeddedData(ref myData);
gs.ImportXMLWorkspaceDocument(gdata);
[VB.NET]
Dim myFile As HttpPostedFile = FileUpload.PostedFile
Dim nFileLen As Integer = myFile.ContentLength

Dim myData As Byte()
myFile.InputStream.Read(myData, 0, nFileLen)

Dim gdata As IGDSData = ctx.CreateObject("esriGeodatabaseDistributed.GDSData")
gdata.TransportType = esriGDSTransportType.esriGDSTransportTypeEmbedded
gdata.set_EmbeddedData(myData)
gs.ImportXMLWorkspaceDocument(gdata)

Creating replicas

The CreateReplica method can be used to create and download a child replica containing a spatial subset of data from a specified set of datasets on the geodata server. The data to be extracted is specified by a GPReplica object. A separate attribute query can be applied to each table or feature class. Related records can be fetched. The CreateReplica method can be used to create CheckOut, OneWay, or TwoWay replicas. Only datasets that are accessible by the database user associated with the geodata server can be replicated.
The following code example shows using a geodata server running in a MapServer's server context to create a single generation replica of all the layers in the map in a personal geodatabase:
[C#]
public static void createreplica()
{
    try
    {
        IServerContext ctx = null;
        GISServerConnection serverConnection = new GISServerConnection();
        serverConnection.Connect("Localhost");
        IServerObjectManager serverManager = serverConnection.ServerObjectManager;
        ctx = serverManager.CreateServerContext("MontgomerySimple", "MapServer");

        IServerContext gsServerContext = null;
        gsServerContext = serverManager.CreateServerContext("MontgomerySimple", 
            "GeoDataServer");
        IGeoDataServer gs = gsServerContext.ServerObject as IGeoDataServer;

        IGPReplicaDescription gpRepDesc = ctx.CreateObject(
            "esriGeodatabase.GPReplicaDescription")as IGPReplicaDescription;
        gpRepDesc.ModelType = esriReplicaModelType.esriModelTypeFullGeodatabase;
        gpRepDesc.SingleGeneration = true;
        gpRepDesc.TransferRelatedObjects = true;

        IMapServer ms = ctx.ServerObject as IMapServer;
        IMapServerObjects mso = ms as IMapServerObjects;
        IMap map = mso.get_Map(ms.DefaultMapName);
        IMapDescription pMapDesc = ms.GetServerInfo(ms.DefaultMapName)
            .DefaultMapDescription;

        gpRepDesc.QueryGeometry = (IGeometry)pMapDesc.MapArea.Extent;
        gpRepDesc.SpatialRelation = esriSpatialRelEnum.esriSpatialRelIntersects;
        IGPReplicaDatasets resds = gsServerContext.CreateObject(
            "esriGeodatabase.GPReplicaDatasets")as IGPReplicaDatasets;

        IDEBrowseOptions aoDEBrowseOptions = gsServerContext.CreateObject(
            "esriGeodatabase.DEBrowseOptions")as IDEBrowseOptions;
        aoDEBrowseOptions.ExpandType = esriDEExpandType.esriDEExpandDescendants;
        aoDEBrowseOptions.RetrieveFullProperties = true;
        aoDEBrowseOptions.RetrieveMetadata = true;
        IDataElements dataelements = gs.get_DataElements(aoDEBrowseOptions);
        for (int t = 0; t < dataelements.Count; t++)
        {
            IDataElement dataelem = dataelements.get_Element(t);
            IGPReplicaDataset rd = gsServerContext.CreateObject(
                "esriGeodatabase.GPReplicaDataset")as IGPReplicaDataset;
            rd.Name = dataelem.Name;
            rd.DatasetType = esriDatasetType.esriDTFeatureDataset;
            rd.RowsType = esriRowsType.esriRowsTypeFilter;
            rd.UseGeometry = true;
            resds.Add(rd);
        }

        //Non-spatial data that do not participate in any relationship, can be replicated or extracted if added to map document.
        //By looping through the table collection from the map, each table is added to IGPReplicaDatasets.
        IDataset ds = null;
        IStandaloneTableCollection tablecoll = map as IStandaloneTableCollection;
        for (int t = 0; t < tablecoll.StandaloneTableCount; t++)
        {
            IStandaloneTable table = tablecoll.get_StandaloneTable(t);
            IGPReplicaDataset rd1 = gsServerContext.CreateObject(
                "esriGeodatabase.GPReplicaDataset")as IGPReplicaDataset;
            ds = table as IDataset;
            rd1.Name = ds.Name;
            rd1.DatasetType = esriDatasetType.esriDTTable;
            rd1.RowsType = esriRowsType.esriRowsTypeFilter;
            rd1.UseGeometry = true;
            resds.Add(rd1);
        }

        resds = gs.ExpandReplicaDatasets(resds);
        gpRepDesc.ReplicaDatasets = resds;

        //Options:
        IGDSExportOptions exo = gsServerContext.CreateObject(
            "esriGeoDatabaseDistributed.GDSExportOptions")as IGDSExportOptions;
        exo.ExportFormat = esriGDSExportFormat.esriGDSExportFormatPersonalGdb;

        // Create a random replica name. If a replica with the same name has been created previously,
        // replica creation fails.
        System.Random randomizer = new System.Random();
        int randomNumber = randomizer.Next(0, int.MaxValue);
        string replicaName = string.Format("replica_{0}", randomNumber.ToString());
        IGDSData gsdata = gs.CreateReplica(gs.DefaultWorkingVersion, replicaName,
            gpRepDesc, null, exo, esriGDSTransportType.esriGDSTransportTypeUrl);

        //For extracting data, comment the call to CreateReplica above and use the ExtractData method instead.
        //IGDSData gsdata = gs.ExtractData(gs.DefaultWorkingVersion,gpRepDesc,exo, esriGDSTransportType.esriGDSTransportTypeUrl);

    }
    catch (Exception ex)
    {
        System.Diagnostics.Debug.WriteLine(ex.Message);
    }
}
[VB.NET]
Public Shared Sub createreplica()
Try
Dim ctx As IServerContext = Nothing
Dim serverConnection As New GISServerConnection()
serverConnection.Connect("Localhost")
Dim serverManager As IServerObjectManager = serverConnection.ServerObjectManager
ctx = serverManager.CreateServerContext("MontgomerySimple", "MapServer")

Dim gsServerContext As IServerContext = Nothing
gsServerContext = serverManager.CreateServerContext("MontgomerySimple", "GeoDataServer")
Dim gs As IGeoDataServer = TryCast(gsServerContext.ServerObject, IGeoDataServer)
Dim gpRepDesc As IGPReplicaDescription = TryCast(ctx.CreateObject("esriGeodatabase.GPReplicaDescription"), IGPReplicaDescription)
gpRepDesc.ModelType = esriReplicaModelType.esriModelTypeFullGeodatabase
gpRepDesc.SingleGeneration = True
gpRepDesc.TransferRelatedObjects = True

Dim ms As IMapServer = TryCast(ctx.ServerObject, IMapServer)
Dim mso As IMapServerObjects = TryCast(ms, IMapServerObjects)
Dim map As IMap = mso.get_Map(ms.DefaultMapName)
Dim pMapDesc As IMapDescription = ms.GetServerInfo(ms.DefaultMapName).DefaultMapDescription

gpRepDesc.QueryGeometry = CType(pMapDesc.MapArea.Extent, IGeometry)
gpRepDesc.SpatialRelation = esriSpatialRelEnum.esriSpatialRelIntersects

Dim resds As IGPReplicaDatasets = TryCast(gsServerContext.CreateObject("esriGeodatabase.GPReplicaDatasets"), IGPReplicaDatasets)

Dim aoDEBrowseOptions As IDEBrowseOptions = TryCast(gsServerContext.CreateObject("esriGeodatabase.DEBrowseOptions"), IDEBrowseOptions)
aoDEBrowseOptions.ExpandType = esriDEExpandType.esriDEExpandDescendants
aoDEBrowseOptions.RetrieveFullProperties = True
aoDEBrowseOptions.RetrieveMetadata = True
Dim dataelements As IDataElements = gs.get_DataElements(aoDEBrowseOptions)

For t As Integer = 0 To dataelements.Count - 1
    Dim dataelem As IDataElement = dataelements.get_Element(t)
    Dim rd As IGPReplicaDataset = TryCast(gsServerContext.CreateObject("esriGeodatabase.GPReplicaDataset"), IGPReplicaDataset)
    rd.Name = dataelem.Name
    rd.DatasetType = esriDatasetType.esriDTFeatureDataset
    rd.RowsType = esriRowsType.esriRowsTypeFilter
    rd.UseGeometry = True
    resds.Add(rd)
Next t

'Non-spatial data that do not participate in any relationship, can be replicated or extracted if added to map document.
'By looping through the table collection from the map, each table is added to IGPReplicaDatasets.
Dim ds As IDataset = Nothing
Dim tablecoll As IStandaloneTableCollection = TryCast(map, IStandaloneTableCollection)
For t As Integer = 0 To tablecoll.StandaloneTableCount - 1
    Dim table As IStandaloneTable = tablecoll.get_StandaloneTable(t)
    Dim rd1 As IGPReplicaDataset = TryCast(gsServerContext.CreateObject("esriGeodatabase.GPReplicaDataset"), IGPReplicaDataset)
    ds = TryCast(table, IDataset)
    rd1.Name = ds.Name
    rd1.DatasetType = esriDatasetType.esriDTTable
    rd1.RowsType = esriRowsType.esriRowsTypeFilter
    rd1.UseGeometry = True
    resds.Add(rd1)
Next t

resds = gs.ExpandReplicaDatasets(resds)
gpRepDesc.ReplicaDatasets = resds

'Options:
Dim exo As IGDSExportOptions = TryCast(gsServerContext.CreateObject("esriGeoDatabaseDistributed.GDSExportOptions"), IGDSExportOptions)
exo.ExportFormat = esriGDSExportFormat.esriGDSExportFormatPersonalGdb

' Create a random replica name. If a replica with the same name has been created previously,
' replica creation fails.
Dim randomizer As New System.Random()
Dim randomNumber As Integer = randomizer.Next(0, Integer.MaxValue)
Dim replicaName As String = String.Format("replica_{0}", randomNumber.ToString())
Dim gsdata As IGDSData = gs.CreateReplica(gs.DefaultWorkingVersion, replicaName, gpRepDesc, Nothing, exo, esriGDSTransportType.esriGDSTransportTypeUrl)

'For extracting data, comment the call to CreateReplica above and use the ExtractData method instead.
'IGDSData gsdata = gs.ExtractData(gs.DefaultWorkingVersion,gpRepDesc,exo, esriGDSTransportType.esriGDSTransportTypeUrl);

Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
End Try
End Sub

Extracting and downloading data

The ExtractData method can be used to extract and download a spatial subset of data from a specified set of datasets. The data to be extracted is specified by a GPReplica object. Both vector and raster data can be extracted. A separate attribute query can be applied to each table or feature class. Related records can be fetched as part of the extract. Only datasets that are accessible by the database user associated with the geodata server connection can be extracted. To extract data, follow the code pattern previously shown for creating a replica, but use the ExtractData method on IGeodataServer, instead of CreateReplica, to extract the data.
To extract the non-spatial data not participating in any relationship, the data must be added to the map document published as service enabled with geodata capability. Since the non-spatial data is not fetched by default, it is required to loop through the tables added to the map and individually add them to the replica dataset collection as shown in the previous code example.

Synchronizing replicas

The ExportReplicaDataChanges, ImportReplicaDataChanges, and ExportAcknowledgement methods can be used to synchronize replicas. The process of synchronizing two replicas, each of which is managed by a geodata server, involves exporting changes from one replica and importing changes into the other replica. The Replica Synchronization tools in ArcGIS for Desktop can be used to perform these operations. Only replicas that are owned by the database user associated with the geodata server can be synchronized.
These methods make it possible to synchronize replicas over standard Web services and allow you to create applications that synchronize replicas on a regularly scheduled basis.
The following code example shows how to use the geodata server to check in replica changes that have been exported to a delta XML document:
[C#]
string fn2 = "c:\\temp\\myDeltas.xml";
System.IO.FileStream f = new System.IO.FileStream(fn2, System.IO.FileMode.Open);
byte[] bytes = new byte[f.Length];
f.Read(bytes, 0, (int)f.Length);

IGDSData data = new GDSDataClass();
data.TransportType = esriGDSTransportType.esriGDSTransportTypeEmbedded;
data.set_EmbeddedData(ref bytes);

gs.ImportReplicaDataChanges
    (esriGDSReplicaImportSource.esriGDSReplicaImportSourceDeltaXmlFile,
    esriReplicaReconcilePolicyType.esriReplicaResolveConflictsInFavorOfImportedChanges, false, data);
[VB.NET]
Dim fn2 As String = "c:\temp\myDeltas.xml"

Dim f As System.IO.FileStream = New System.IO.FileStream(fn2, System.IO.FileMode.Open)
Dim bytes() As Byte
f.Read(bytes, 0, f.Length)

Dim data As IGDSData = New GDSDataClass()
data.TransportType = esriGDSTransportType.esriGDSTransportTypeEmbedded
data.EmbeddedData = bytes

gs.ImportReplicaDataChanges(esriGDSReplicaImportSource.esriGDSReplicaImportSourceDeltaXmlFile,
esriReplicaReconcilePolicyType.esriReplicaResolveConflictsInFavorOfImportedChanges, False, data)