Error using GeometryService.union

2090
10
12-20-2011 01:26 AM
TiagoRibeiro
Occasional Contributor
Hi,

My application has a function that performs a query based in the current map.graphcis. If there are more than 1 graphic I perform a union, and here the problem starts.
This works well most of the times, but depending in the number/type of geometries to be "unified", sometimes the union throws two types of errors:

  1. One that I handle using the errback function

  2. One that returns a 500 Internal Serve error code

The first one the error returned is "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Parameter name: input". This error occurs when I send more than 100 geometries. Does anyone have any idea how to get around this?
The second one doesn't give out a specific error... I noticed that it happens when I send big geometries. I'll try to see the server logs and try to find some clues.
Can anyone give me a help/hint?
Thanks
0 Kudos
10 Replies
TiagoRibeiro
Occasional Contributor
Hi,
My application has a function that performs a query based in the current map.graphcis. If there are more than 1 graphic I perform a union, and here the problem starts.
This works well most of the times, but depending in the number/type of geometries to be "unified", sometimes the union throws two types of errors:

  1. One that I handle using the errback function

  2. One that returns a 500 Internal Serve error code

The first one the error returned is "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Parameter name: input". This error occurs when I send more than 100 geometries. Does anyone have any idea how to get around this?
The second one doesn't give out a specific error... I noticed that it happens when I send big geometries. I'll try to see the server logs and try to find some clues.
Can anyone give me a help/hint?
Thanks


I solved the 500 internal server error. I increased the allowed content length on IIS.
But the first one persists and I don't know if it's a problem of configuration on the server or a problem with the geometries.
The error occurs when:

  1. A lot of geometries are sent (more then 100)

  2. A few, but complex geometries are sent.

If this question is better suitable for another forum, please tell me witch one to post it.
If anyone has any idea in how to solve this, please do tell!

Thanks
0 Kudos
SiqiLi
by Esri Contributor
Esri Contributor
0 Kudos
TiagoRibeiro
Occasional Contributor
Have you tried a proxy page?
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/ags_proxy.htm


Hi, thanks for your response.
I configured the proxy, but I still get the same error.
I tested with and without the proxy, and as I increase the complexity of the geometries to unify, the error "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property." appears exactly at the same point... any other ideas?
I implement a fallback plan, that when the union fails, I just get the extents of the geometries, and use that to perform the query, but I still would like to get the union to work...
0 Kudos
SiqiLi
by Esri Contributor
Esri Contributor
Just did a further research and found you may experiencing the known bug with the javascriptserializer::MaxJsonLength property. 
[#NIM066822 MaxJsonLength exceeded error message is returned when an input geometry to an SOE contains a large number of vertices ]

I checked the bug status, it is fixed in version 10 SP3.  Have you installed SP3?
0 Kudos
TiagoRibeiro
Occasional Contributor
Just did a further research and found you may experiencing the known bug with the javascriptserializer::MaxJsonLength property. 
[#NIM066822 MaxJsonLength exceeded error message is returned when an input geometry to an SOE contains a large number of vertices ]
I checked the bug status, it is fixed in version 10 SP3.  Have you installed SP3?


Yes I have. I've just ran the PatchFinder and I already have the SP3 of all products.

I tried to alter the web.config in order to set maxJsonLength like this:
<system.web.extensions>
 <scripting>
   <webServices>
  <jsonSerialization maxJsonLength="50000000">
  </jsonSerialization>
   </webServices>
 </scripting>
</system.web.extensions>

Still the same result...
0 Kudos
TiagoRibeiro
Occasional Contributor
Hi, and Happy Holidays everyone.
Can anyone, from ESRI or otherwise, help me with this? I already tried using the esri geometry service, http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer, and had exactly the same result:
[HTML]"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Parameter name: input"[/HTML]
I'll try to put something online for you to test it.
0 Kudos
TiagoRibeiro
Occasional Contributor
I've set up a simple example to show you what's happening.
Here, http://193.136.119.25/tests/test_union.html, you'll find a map with only one layer.

When you click on the buttons, a query will be performed, the results will be added to the map and then I try to perform the union based in the graphics of the map. The only difference is that one works and the other doesn't. Use the console to see what's happening.
You can also switch between ESRI and local geometry services... the results will be the same.

Is it a problem with the geometries? Is it something I can configure in the server? Is it just a limitation of the geometry service?
0 Kudos
HemingZhu
Occasional Contributor III
I've set up a simple example to show you what's happening.
Here, http://193.136.119.25/tests/test_union.html, you'll find a map with only one layer.

When you click on the buttons, a query will be performed, the results will be added to the map and then I try to perform the union based in the graphics of the map. The only difference is that one works and the other doesn't. Use the console to see what's happening.
You can also switch between ESRI and local geometry services... the results will be the same.

Is it a problem with the geometries? Is it something I can configure in the server? Is it just a limitation of the geometry service?


The problem usually has something to do with the length of the polyon JSON string. One solution you could try is to generalize the polygons prior to union to reduce the length of the JSON string. something this this:
var generalizeParams = new esri.tasks.GeneralizeParameters();
generalizeParams.geometries =esri.getGeometries(map.graphics.graphics);
geometryServiceLocal.generalize(generalizeParams, function(geometries){
     geometryServiceLocal.union(esri.getGeometries(map.graphics.graphics), function(geometry){
           ......
     });
});




0 Kudos
TiagoRibeiro
Occasional Contributor
The problem usually has something to do with the length of the polyon JSON string. One solution you could try is to generalize the polygons prior to union to reduce the length of the JSON string. something this this:
var generalizeParams = new esri.tasks.GeneralizeParameters();
generalizeParams.geometries =esri.getGeometries(map.graphics.graphics);
geometryServiceLocal.generalize(generalizeParams, function(geometries){
     geometryServiceLocal.union(esri.getGeometries(map.graphics.graphics), function(geometry){
           ......
     });
});

Hi, and happy new year everyone!
Thanks for your reply Heming, but now I have an error using the Generalize task:

  • "Nullable object must have a value." when using 4 geometries.

  • "'geometries' parameter is invalid." when using 5 geometries.

The second one I think it's related with the previous problem, but the first one I have no idea. I think its something simple, but I don't get what...
0 Kudos