Feature Services

Feature Services allow you to serve features over the Internet and provide the symbology to use when displaying the features. Features are organized into layers on which clients can execute queries and perform edits. Feature services provide templates which can be used for an enhanced editing experience on the client. Data from relationships and non-spatial tables can also be queried and edited using Feature Services.


The service offers the following capabilities:



WSDL syntax


http://<Web Server Hostname>/<ArcGIS Instance>/services/<ServiceName>/MapServer/FeatureServer?wsdl



Working with feature services


Get information about the contents of the service


A feature service can provide both spatial and non-spatial data. The GetLayers method can be used to get information about the spatial data on the service. The method returns an array of GraphicFeatureLayer objects where each, also refer to as a layer, describes a distinct set of features. The GetTables method can be called to get information about the non-spatial data only or called to get information about all data (both spatial and non-spatial). This method returns an array of DataObjectTable objects. A GraphicFeatureLayer is a DataObjectTable (also referred to as a table), and because of this, the method can return both spatial and non-spatial data in the same array.


Information provided by a DataObjectTable includes types, templates and properties (fields in the database). Types represent unique values from a unique value renderer. A template contains a prototypical instance of an object and is used to define the default values for a new object.


A DataObjectTable will also return information describing relationships, time and attachments for data that has been published with these properties. This can be used when making queries on the service. For example, with relationships, you can query a table and have the result return corresponding objects from a related table. With time, you can execute queries which return objects that existed during a specific period of time.


GraphicFeatureLayer objects inherit all of these properties and also include properties describing spatial information such as the spatial reference and spatial extent. Renderer and symbol information is also provided by the object through the LayerDrawingDescription.


Querying the feature Service


To get data from the service, queries can be executed on the layers and tables. Some methods are provided to query many layers or tables at once while others are provided to query individual layers or tables.


The QueryFromService and GetServiceObjectCount methods allow you to query many layers or tables at once. These methods take an array of GFSTableDescription as well as a geometry that defines the area in which to apply the query. Each of these objects in the array includes a layer or table and optionally a definition expression. The GetServiceObjectCount method can be used to get the number of objects returned from the query while QueryFromService returns the actual objects. These methods are useful for operations like pan and zoom where when the extent changes, features need to be fetched from the service for the new extent.


The Query, QueryIDs and GetCount methods allow you to query individual layers and tables. These methods take a QueryFilter which allows you to define the query using attribute expressions, time and/or spatial filters. This method also accepts a FIDSet which allows you to query using an array of ObjectIDs. An ObjectID is a system attribute available in all layers and tables that uniquely identifies a row within a table or layer.


The GetCount method is used to get the number of rows that will be returned by the query. If the number of rows is relatively small, for example, you can use the Query method which returns the results of the query. If the number of rows is large, you may want to use paging to return the results in a series of smaller queries. To implement paging, use the QueryIDs method to get an array of the ObjectIDs that satisfy the query condition. The ObjectIDs can then be used with the QueryFilter’s FIDSet property to execute a series of queries each returning a subset of the result.


The QueryRelatedObjects method allows you to execute queries that return related rows. This method takes a list of ObjectIDs from the source layer or table and returns objects from the related layer or table. When implementing an identify tool, for example, you may want to use this method to allow results to be expanded to include related rows.


The QueryAttachmentInfos and QueryAttachmentData methods allow you to query information and the actual attachments that are related to features that have been published with these properties. The QueryAttachmentInfos method takes a list of ObjectIDs from the source layer (IDsOfObjectstoQuery) and returns an array of AttachmentInfo objects containing all of the related attachments as well as the properties of the attachment including; AttachmentID, ContentType (ex. PDF, JPG) Name, ParentID (the layer or table ID) and the Size of the attachment. Once you have the IDs for the attachments, you can use the QueryAttachmentData to access the attachments.


Query Results - Results from queries are returned as ServiceData objects. When executing a query, use the ServiceDataOptions object to define the format of the results. Supported formats are: "Native", "Amf", and "JSON". The ServiceData object returned from the result includes the ServiceDataOptions object that was passed in with the query.


The output spatial reference can also be specified when running a query. This is useful in cases where the client requires features in a spatial reference other than the default returned from the service.


Results may also be returned as either grouped or ungrouped. Ungrouped means that all results are returned in one array while grouped means that results are returned in set of arrays. The Query method always returns results ungrouped. The QueryFromService method always returns results grouped where arrays are provided with the results for each layer or table. You can choose either grouped or ungrouped results for the QueryRelatedObjects method. In this case, when grouped is selected, the method returns results with an array for each id from the source.


For grouped results, the ServiceData.Object method returns a DataObjectGroups object which allows you to step through the results one group at a time. For ungrouped results, the ServiceData.Object method returns DataObjects which allows you to step through all results.


Definition Expression -The Query and QueryRelatedObjects methods and the GFSTableDescription object takes a DefinitionExpression. Definition expressions are strings and are separate from and can be applied in addition to QueryFilters. Definition expressions can be used to apply queries to a specific type within a layer or table. You can also use a definition expression to easily apply the same query to all layers in the service.


Etags - An Etag is a property (ServiceDataOptions.ETag) that you can pass when querying the feature service. Etags allow browsers to cache the results from queries. With Etags, you can determine if the result of a query on the server is the same as before, and if so, results are not returned.




Methods are provided that allow the application to apply edits to the underlying geodatabase through the service. The ApplyEdits method allows you to apply many edits to many layers and tables at once. The Add, Update, Delete and DeleteByID methods allow you to apply edits to a single layer or table. Each call to any of these methods results in a transaction in the underlying geodatabase used by the service.


To apply updates, first get the data to update from the feature service by executing a query. Data is returned from the query as a ServiceData object, whose Object property includes an array of DataObject objects and GraphicFeature objects. GraphicFeature inherits from a DataObject and therefore includes attributes as well as geometry. To update an attribute, use DataObject.Properties, a PropertySet, to set the new values for the properties. To apply a change to a shape, set the GraphicFeature.Geometry property. Once all changes are made, use the Update or ApplyEdits methods to apply the changes on the service.


Note: Some attributes, such as the ObjectID or GlobalID, are not editable and changes to these attributes are ignored when the updates are applied.


Deletes can be applied by either providing an array of ObjectIDs or by providing a query expression. You can get the ObjectIDs by querying the service and getting the ObjectID attribute values from the DataObjects. When deleting using a query expression, the query can involve attribute expressions, time and/or spatial filters. The DeleteByID and ApplyEdits methods use an ObjectID array for deletes while the Delete method uses a QueryFilter.


To add new rows or features, first create a new DataObject or GraphicFeature object. Next, set the properties of the new object equal to the properties from the template you wish to use (TemplateInfo object). This sets the default values which you can then change as needed. When you are ready to apply the new rows or features use the Add or ApplyEdits methods to apply them on the service.


There are also edit methods provided that allow you to add, delete and update attachments through the feature service to features that have been published with this property. To add new attachments first create an array of AttachmentData objects with the attachments you wish to add. Then use the AddAttachments method to add the attachments to a specified layer. To update attachments use an array AttachmentData objects with the attachments and the changes you would like to apply along with the layer ID to the UpdateAttachments method. Attachments can also be deleted by providing an array of AttachmentIDs and the layer ID to the DeleteAttachments method.


When edits are applied to the service, an array of EditResult objects is returned. You can step through the results to see if individual edits were applied successfully and in the case of adds, you will get the new ObjectID and GlobalID values assigned on the service.



Proxy method



Adds features/objects to a layer/table.


Adds attachments to a layer and returns the results.


Performs Adds, Deletes and Updates.


Deletes features/objects in a layer/table that satisfy query filter.


Deletes attachments in a layer using an array of AttachmentIDs.


Deletes the features/objects whose ObjectIDs match the input.


Returns the count of features/objects in a layer/table that satisfy query filter. 


Returns Layers in Service.


Gets the count of features/objects in the Service that satisfy query filter.


Gets all tables or stand alone tables in the Service depending on the boolean argument’s value.


Gets the features/objects that satisfy the query criteria.


Queries and returns attachments of the input attachment identifier array.


Queries and returns an array of objects containing AttachmentIDs and the properties of the attachments.


Gets the features/objects in the Service that satisfy the criteria in layer/table descriptions and overlap with the geometry. 


Queries and returns rich HTML formatted attributes for one or more rows.


Gets the ObjectIDs of the features/objects that satisfy the search criteria.


Gets the related features/objects that satisfy the criteria.


Updates attachments from a layer.


Updates features/objects in the Service.