Hi guys, I just start using SOE in ArcGIS Server 10.1 and find something strange here. When I create a RESTSOE project from Visual studio 2010 template, the handler is like this: private byte[] SampleOperHandler(NameValueCollection boundVariables,
JsonObject operationInput,
string outputFormat,
string requestProperties,
out string responseProperties)
{
responseProperties = null;
string parm1Value;
bool found = operationInput.TryGetString("parm1", out parm1Value);
if (!found || string.IsNullOrEmpty(parm1Value))
throw new ArgumentNullException("parm1");
string parm2Value;
found = operationInput.TryGetString("parm2", out parm2Value);
if (!found || string.IsNullOrEmpty(parm2Value))
throw new ArgumentNullException("parm2");
JsonObject result = new JsonObject();
result.AddString("parm1", parm1Value);
result.AddString("parm2", parm2Value);
return Encoding.UTF8.GetBytes(result.ToJson());
}
After adding this soe file to ArcGIS Server and invoke the rest service at: http://localhost:6080/arcgis/rest/services/demo/MapServer/exts/RestSOE/sampleOperation?parm1=1111&pa...the soe will throw ArgumentNullException when it trying to retrieve parm1 value.Then I change handler code to: private byte[] SampleOperHandler(NameValueCollection boundVariables,
JsonObject operationInput,
string outputFormat,
string requestProperties,
out string responseProperties)
{
responseProperties = null;
object parm1Value;
bool found = operationInput.TryGetObject("parm1", out parm1Value);
if (!found || parm1Value == null || string.IsNullOrEmpty(parm1Value.ToString()))
throw new ArgumentNullException("parm1");
object parm2Value;
found = operationInput.TryGetObject("parm2", out parm2Value);
if (!found || parm2Value == null || string.IsNullOrEmpty(parm2Value.ToString()))
throw new ArgumentNullException("parm2");
JsonObject result = new JsonObject();
result.AddString("parm1", parm1Value.ToString());
result.AddString("parm2", parm2Value.ToString());
string aaa;
found = operationInput.TryGetString("parm1", out aaa);
if (!found || string.IsNullOrEmpty(aaa))
{
result.AddString("parm1Exist", "False");
}
else
{
result.AddString("parm1Exist", "True");
}
return Encoding.UTF8.GetBytes(result.ToJson());
}
then result json will be:{
"parm1": "1111",
"parm2": "222",
"parm1Exist": "False"
}
It looks like JsonObject.TryGetObject() function works fine while JsonObject.TryGetString() not working.Am i right?