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:
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">Init</SPAN><SPAN class="punctuation token">(</SPAN>IServerObjectHelper pSOH<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
serverObjectHelper <SPAN class="operator token">=</SPAN> pSOH<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>serverObjectHelper<SPAN class="punctuation token">.</SPAN>ServerObject<SPAN class="punctuation token">.</SPAN>TypeName <SPAN class="operator token">==</SPAN> <SPAN class="string token">"MapServer"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
m_mapServer <SPAN class="operator token">=</SPAN> serverObjectHelper<SPAN class="punctuation token">.</SPAN>ServerObject <SPAN class="keyword token">as</SPAN> IMapServer<SPAN class="punctuation token">;</SPAN>
m_mapServerDataAccess <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IMapServerDataAccess<SPAN class="punctuation token">)</SPAN>serverObjectHelper<SPAN class="punctuation token">.</SPAN>ServerObject<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
IMapServerInfo mapServerInfo <SPAN class="operator token">=</SPAN> m_mapServer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetServerInfo</SPAN><SPAN class="punctuation token">(</SPAN>m_mapServer<SPAN class="punctuation token">.</SPAN>MapName<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
IMapLayerInfos mapLayerInfos <SPAN class="operator token">=</SPAN> mapServerInfo<SPAN class="punctuation token">.</SPAN>MapLayerInfos<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">for</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">int</SPAN> layerId <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN> layerId <SPAN class="operator token"><</SPAN> mapLayerInfos<SPAN class="punctuation token">.</SPAN>Count<SPAN class="punctuation token">;</SPAN> layerId<SPAN class="operator token">++</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
IFeatureClass fc <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IFeatureClass<SPAN class="punctuation token">)</SPAN>m_mapServerDataAccess<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetDataSource</SPAN><SPAN class="punctuation token">(</SPAN>m_mapServer<SPAN class="punctuation token">.</SPAN>MapName<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> layerId<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>fc <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
IDataset fsDataset <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IDataset<SPAN class="punctuation token">)</SPAN>fc<SPAN class="punctuation token">;</SPAN>
m_workspace <SPAN class="operator token">=</SPAN> fsDataset<SPAN class="punctuation token">.</SPAN>Workspace<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>m_workspace <SPAN class="operator token">!=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">break</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">if</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>m_workspace <SPAN class="operator token">==</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">throw</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">ArcGISAccessException</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Workspace could not be opened"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> props <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>m_workspace<SPAN class="punctuation token">.</SPAN>ConnectionProperties<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> factory <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FileGDBWorkspaceFactory</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> editWorkspace <SPAN class="operator token">=</SPAN> factory<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Open</SPAN><SPAN class="punctuation token">(</SPAN>props<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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:
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">byte</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="token function">ModifyFeature</SPAN><SPAN class="punctuation token">(</SPAN>NameValueCollection boundVariables<SPAN class="punctuation token">,</SPAN> JsonObject operationInput<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">string</SPAN> outputFormat<SPAN class="punctuation token">,</SPAN>
<SPAN class="keyword token">string</SPAN> requestProperties<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">out</SPAN> <SPAN class="keyword token">string</SPAN> responseProperties<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
responseProperties <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> featureWorkspace <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IFeatureWorkspace<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>m_workspace<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> editWorksopace <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>IWorkspaceEdit<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>m_workspace<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> featureClass <SPAN class="operator token">=</SPAN> featureWorkspace<SPAN class="punctuation token">.</SPAN><SPAN class="token function">OpenFeatureClass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"FC"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> feature <SPAN class="operator token">=</SPAN> featureClass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Search</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">NextFeature</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> index <SPAN class="operator token">=</SPAN> featureClass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindField</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"MyAttribute"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>featureClass<SPAN class="punctuation token">.</SPAN>Fields<SPAN class="punctuation token">.</SPAN>Field<SPAN class="punctuation token">[</SPAN>index<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>Editable<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
editWorksopace<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartEditing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
editWorksopace<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartEditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
feature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">set_Value</SPAN><SPAN class="punctuation token">(</SPAN>index<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Hallo"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
feature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Store</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
editWorksopace<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StopEditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
editWorksopace<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StopEditing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">var</SPAN> result <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">JsonObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
result<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddString</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Status"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"OK"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> Encoding<SPAN class="punctuation token">.</SPAN>UTF8<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetBytes</SPAN><SPAN class="punctuation token">(</SPAN>result<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToJson</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>I still get the same error, although I even check if the field of that feature is editable.