Select to view content in your preferred language

Editing standalone ORACLE table

1805
5
04-26-2011 04:45 AM
SubrahmanyamMuthukumar
New Contributor
I have an ORACLE 11g standalone table created in ArcCatalog, registered with a geodatabase, but not registered as versioned.  I have also created a Map service, with FeatureService access to this table.
I am able to update this table by using the REST API directly from the FeatureService page in a browser using JSON.  But I am not able to make updates when I access the FeatureService through a Silverlight front end application.

The layer is defined as under in XAML:
<esri:FeatureLayer ID="INCIDENTS"                               Url="http://gaatlitvgis04d/ArcGISTEST/rest/services/CYO_TEST/FeatureServer/1"
      Mode="OnDemand" DisableClientCaching="True" OutFields="*" AutoSave="True"
      Initialized="FeatureLayer_Initialized" EndSaveEdits="Insert_EndSaveEdits"
      SaveEditsFailed="Insert_SaveEditsFailed" ></esri:FeatureLayer>

In code-behind, I query the INCIDENTS layer by a customer ID field and populate a FeatureDataGrid.  For detailed editing, I have created a custom editing form that responds to the SelectionChanged event of the featureDataGrid, consisting of a GRID with several textbox and combobox controls, and I set the GRID's DataContext to the selected graphic.  The controls are all twoway-bound to the respective attributes of interest.  I am able to view all the attributes as expected from the database, but when anything is updated in the controls, I get a "POST applyEdits" update failure as
{"error":{"code":400,"message":"Unable to complete  operation.","details":["Unable to apply edits"]}}

I am unable to understand why I can apply edits directly from the FeatureService page using JSON, but not through Silverlight.  I have created other applications using the Editor widget that successfully edit feature layers with geometry using Silverlight - is there any notable difference between standalone tables without geometry and tables with geometry when they are exposed in Silverlight that I should be aware of?  Could it be a permissions issue?  Or could it be a data serialization issue within Silverlight?

I would appreciate any help working through this issue, because it is fundamental to our workflow.
Thanks,
Muthu
0 Kudos
5 Replies
JenniferNery
Esri Regular Contributor
It is hard to tell what could be different in your Silverlight application and request made from your web browser unless you look at the web requests on Fiddler. Can you try running Fiddler? Kindly look at Inspectors > Web Forms tab and try to use the same parameters in the web browser.
0 Kudos
SubrahmanyamMuthukumar
New Contributor
Thanks, Jennifer. 
I ran Fiddler as you suggested.  In the application, I first query a customer location point feature layer and populate a FeatureDataGrid with the customer query results.  On this FeatureDataGrid's "SelectionChanged" event, I run a second query to retrieve all incidents associated with that particular customer row, and populate a second FeatureDataGrid with the incidents query results (ObjectIDs 2,3,5,6,7). Using this FeatureDataGrid's "SelectionChanged" event, I reach the custom editing form, whose controls are populated with the selected incident's attributes.  I change one attribute value, the INC_DTM (Incident Date) attribute, and immediately get an "ESRI.ArcGIS.Client.Tasks.TaskFailedEventArgs" error.  In Fiddler, I noted the following:

In the Web Sessions pane,
-------------------------------------------------------------------------------------
#         Result         URL
-------------------------------------------------------------------------------------
50   401       ......./rest/services/CYO_TEST/FeatureServer/1/applyEdits
51   200       ......./rest/services/CYO_TEST/FeatureServer/1/applyEdits
-------------------------------------------------------------------------------------
For the Request, #50, under Inspectors -- Webforms (Body), I get
(Row 1 ) Name = adds
(Row 1)  Value (reformatted and edited for clarity):
[
  {"attributes":
    {
      "OBJECTID":2,
      "GATE_STATUS":"OPEN",
      "INC_TYPE":"SERVICE",
      "INC_DTM":1297659600000,
      "INC_ID":"tstww",
      "SUMMARY":"SUMMARY - Customer has <snip.. long text ..snip> they release at once.",
      "STATEMENT":"STATEMENT - This customer is <snip.. long text ..snip> to prevent delays.",
      "GEO_LOC_SA":16370068522720,
      "CINC_ID":3,
      "PROP_RES":"RESOLUTION - Escalate power <snip.. long text ..snip> for congestion resolution.",
      "RES_DTM":1298246400000,
      "RES_ID":"tnbjf",
      "CUST_FK":null
    }
  },
  :   <snip ... similar details for OBJECTIDs 3,5,6 ...snip>
  :
  {"attributes":
    {
      "OBJECTID":7,
      "GATE_STATUS":"OPEN",
      "INC_TYPE":"SERVICE",
      "INC_DTM":1303603200000,
      "INC_ID":"tstww",
      "SUMMARY":"ENTER SUMMARY DETAILS HERE, MUTBOB",
      "STATEMENT":"ENTER STATEMENT DETAILS HERE MUTBOB",
      "GEO_LOC_SA":16370068522720,
      "CINC_ID":7,
      "PROP_RES":"ENTER RESOLUTION DETAILS HERE MUTBOB",
      "RES_DTM":1303689600000,
      "RES_ID":"tstww",
      "CUST_FK":null
    }
  }
]
(Row 2) Name = f
(Row 2)  Value = json
-------------------------------------------------------------------------------------
Below that, under WebView, I get
"Server Error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied."

For the response, #51, under WebView, I get
{"error":{"code":400,"message":"Unable to complete operation.","details":["Unable to apply edits"]}}
-------------------------------------------------------------------------------------
I tried an "Update Features" from the REST API.  In Fiddler, again, I received a 401 result for the Request, as under
For the Request, under Inspectors -- Webforms (Body), I get
(Row 1 ) Name = features
(Row 1)  Value :
[
{
      "attributes" : {
        "OBJECTID" : 6,
        "SUMMARY" : "SUMMARY BBBBBB"
      }
    }
]
(Row 2) Name = f
(Row 2)  Value = pjson
-------------------------------------------------------------------------------------
Below that, under WebView, I get
"Server Error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied."

For the response however, under WebView, I get
{ "updateResults" : [ { "objectId" : 6, "globalId" : null, "success" : true } ]}
and the updates are committed to the database!
-------------------------------------------------------------------------------------

I also tried applyEdits from the REST API, with similar results, for instance, under WebView,
{ "addResults" : [ ], "updateResults" : [ { "objectId" : 6, "globalId" : null, "success" : true } ], "deleteResults" : [ ]}
even though the Request reports the 401 Server Error...
-------------------------------------------------------------------------------------

In the MapService permissions, I am an authorized user under a role (and so is ArcGISSOC).  I am allowed to make changes to the database.  I can make changes using the REST API with no additional entry credentials. I am able to view the data correctly in the silverlight application.  What is different when I access the same service through Silverlight?  I see that the request through Silverlight seems to be "adds" under an applyEdits "json" process (is the applyEdits process in Silverlight trying to add 5 features?), whereas in the REST API, it is an appropriate updateFeatures "pjson" process or applyEdits "pjson" process with only the update values sent...

Hope this helps you in understanding the situation...  Thanks, again...
0 Kudos
JenniferNery
Esri Regular Contributor
You're right that your Silverlight app will create a request that includes all fields not only the fields that were changed. We are looking into optimizing this in the future.

Can you try to use ApplyEdits on the web browser too? This explains the expected syntax: http://help.arcgis.com/en/arcgisserver/10.0/apis/rest/fsedits.html. You can copy the parameters from Fiddler under WebForms.

How did you secure your service? What is your web browser's security setting on User Authentication? Your Silverlight app use the same authentication as your browser so I'm trying to determine why there is a 401 error on SL app but not on browser. I think that if you can mimic the web request made by your SL app, we can narrow down the problem.
0 Kudos
SubrahmanyamMuthukumar
New Contributor
Here are some updates to this posting...
================================================
1] Can you try to use ApplyEdits on the web browser too?

The HTTP request goes out with the following JSON syntax

---------------------------------------------------------------
adds
---------------------------------------------------------------
updates
[
{
      "attributes" : {
        "CINC_ID" : 1,
        "INC_RESOLUTION" : "RESOLUTION 1",
        "CUST_FK" : 16185095382380
      }
    }
]
--------------------------------------------------------------
deletes
--------------------------------------------------------------
f
pjson
-------------------------------------------------------------
and the WebView says Server Error, 401 - Unauthorized etc...,
and the failed response reads
{ "error" : { "code" : 400, "message" : "Unable to complete operation.", "details" : [ "Unable to apply edits" ] } }
-------------------------------------------------------------
However, the following JSON syntax worked perfectly
[
{
      "attributes" : {
        "CINC_ID" : 1,
        "INC_RESOLUTION" : "RESOLUTION 1",
        "CUST_FK" : 16185095382380.0
      }
    }
]
-------------------------------------------------------------
with the WebView of the response being
{ "addResults" : [ ], "updateResults" : [ { "objectId" : 1, "globalId" : null, "success" : true } ], "deleteResults" : [ ]}
-------------------------------------------------------------
Now, here's the deal.  The FeatureService REST page describes the "CUST_FK" field as esriFieldTypeDouble, while in ORACLE the field is described as Number of Precision 14 and Scale 0.  The syntax seems to be passing the data attribute for CUST_FK as an integer and failing, but if I set the attribute with a decimal place and a zero after, it works fine.
Seems to me that there is a type mismatch here, but the error message very cryptically and generically reports a 401 Unauthorized Access error, leading us up a wrong alley.
I did try setting the ORACLE field as Number (15, 1), same results -- the data passed seems to be an integer and what is expected is a double.

My original question therefore stands, albeit slightly differently.  How do I edit the data through a Silverlight application?
When I set AutoSave = true on my featurelayer, it attempts to send over the JSON string for ALL the records (not just the record that has currently been edited!), and secondly, Fiddler identifies the Silverlight JSON syntax to be an "applyEdits -- add" process, when it should be an "applyEdits - update" process.  If AutoSave is set to true, I have no control over how the data is sent, so I can't make changes to ensure that the CUST_FK value is sent across with a "####.0" to ensure that it is sent as a double.

So, can anybody suggested anything?  Much gratitude for your assistance, Jennifer, it indeed helped me narrow down the problem!

Muthu
0 Kudos
dotMorten_esri
Esri Notable Contributor
In order to update a feature in a featurelayer, the feature must be present in the layer. If you "add" a graphic to the featurelayer, it becomes an add, and if you modify an existing element, it becomes an Update (and of course if you remove one, it becomes a delete).
Ie
This:
myLayer.Graphics.Add(myNewGraphic);
is very different from:
myLayer.Graphics[0].Attributes["ATTRIBUTE"] = "NewValue";
0 Kudos