AnsweredAssumed Answered

update features in mapservice

Question asked by HimBromBeere on May 2, 2018
Latest reply on May 7, 2018 by HimBromBeere

I am using a SOE on top of a MapService in order to enable complex editing of the features in my File-Geodatabase. We use a SOE as we have much ArcObjects-code in our code-base that wraps rows from within a table to actual features. So in fact a feature consists of several rows in different tables, thus updates to a single row should be notified by the others. We´re also using topological edits which I suppose a feature-service can´t handle.


When I try to edit a feature I get the following error:

Workspace or data source is read only.

If I understand things right, a map-service is just for presenting a map, not for modifying the data. This is where a feature-service would come into play, which however does not have support for a Server-object-extension and thus won´t handle our business-logic very well. 


I´ve already tried to read the connection-properties of the underlying map-service and re-open it:


public void Init(IServerObjectHelper pSOH)
     serverObjectHelper = pSOH;

     if (serverObjectHelper.ServerObject.TypeName == "MapServer")
          m_mapServer = serverObjectHelper.ServerObject as IMapServer;

          m_mapServerDataAccess = (IMapServerDataAccess)serverObjectHelper.ServerObject;

     IMapServerInfo mapServerInfo = m_mapServer.GetServerInfo(m_mapServer.MapName[0]);
     IMapLayerInfos mapLayerInfos = mapServerInfo.MapLayerInfos;

     for (int layerId = 0; layerId < mapLayerInfos.Count; layerId++)
          IFeatureClass fc = (IFeatureClass)m_mapServerDataAccess.GetDataSource(m_mapServer.MapName[0], layerId);
          if (fc != null)
               IDataset fsDataset = (IDataset)fc;
               m_workspace = fsDataset.Workspace;
          if (m_workspace != null)
     if(this.m_workspace == null)
          throw new ArcGISAccessException("Workspace could not be opened");

     var props = this.m_workspace.ConnectionProperties;
     var factory = new FileGDBWorkspaceFactory();
     var editWorkspace = factory.Open(props, 0);


However this yields to the examt same error. I can´t see what I´m doing different than the code from the samples.


I also noticed that I am able to edit the data in the geodatabase in ArcMap without any problems, even when it is used by the map-service.


EDIT: To limit the cause of error I set up a completely new service that references a newly created File-Geodatabase containing only a single feature within a featureclass ("FC"). Now I update that feature within my request-handler:


private byte[] ModifyFeature(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat,
              string requestProperties, out string responseProperties)
     responseProperties = null;
     var featureWorkspace = (IFeatureWorkspace) this.m_workspace;
     var editWorksopace = (IWorkspaceEdit) this.m_workspace;
     var featureClass = featureWorkspace.OpenFeatureClass("FC");
     var feature = featureClass.Search(null, false).NextFeature();
     var index = featureClass.FindField("MyAttribute");
     if (featureClass.Fields.Field[index].Editable)

          feature.set_Value(index, "Hallo");

     var result = new JsonObject();
     result.AddString("Status", "OK");
     return Encoding.UTF8.GetBytes(result.ToJson());

I still get the same error, although I even check if the field of that feature is editable.