URL length limits

5427
12
Jump to solution
05-30-2012 08:50 PM
ChristinaLaurier
New Contributor III
The application work such that:
-the user search's for an html atlas page of a particular species; on the atlas page there is a link to the interactive map
-the URL parameters (science name,commonname, synonyms, etc) from the atlas page get passed to the map
-the map queries all layers within the map service for these parameters and loads the corresponding points

The application however exceeds the URL length limit and our synonyms parameter has been restricted to keep the URL string under this limit.It seems that the application is using a get function rather than a post

-I am trying to solve this so that we can include all synonyms.
-I have read about the use of a proxy page as it uses a POST method but how would I go about using one?
   -download a proxy.jsp; add the map services to the proxy page
      -but how do I call upon the proxy page when the layer gets loaded? (in MapManager.mxml)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChristinaLaurier
New Contributor III
Hi,

thanks for all the help!!

the solution actually involved the Identify widget;  In our existing identify widget, we had configured the URLquery (as we did in the MapManager.mxml) thus, the synonyms string would get tacked on to the end of URL again (exceeding the length limit). However, the newest version of the Identify widget seems to solve this issue.

View solution in original post

0 Kudos
12 Replies
sapnas
by
Occasional Contributor III
I'm not sure if it works in your case. one way to accomplish this is to split up the parameters to your max URL lenght limit and send a http request to the server. initialize a counter  and increment it for every request sent. when you receive the http response decrement the counter until it reaches zero and then load the corresponding points.
0 Kudos
TrevorWeiland
New Contributor III
Ah, URL length limits are fun and are really a problem for client side mash up applications.  You might want to discuss this security measure with whomever manages it as it will cause you nothing but problems even if you solve this one.  The web application uses get for the rest services and tacks on a bunch of parameters to retrieve the specific tiles it needs to build the map.  You never see these requests in the browser but you can see them with Fiddler, firebug, wireshark, etc.

I have never used a proxy page to call up the application so I can't help you there.
0 Kudos
ChristinaLaurier
New Contributor III
ok, so this is the chunk of code that deals with formatting and passing the URL parameters
===================================================================================================
private function addLayerToMap(layerObject:Object):void
   {
    const label:String = layerObject.label;
    const type:String = layerObject.type;
    const url:String = layerObject.url;
    const alpha:Number = Number(layerObject.alpha);
    const visible:Boolean = layerObject.visible;
    const visibleLayers:String = layerObject.visibleLayers;
    const mode:String = layerObject.mode;
    const proxyUrl:String = m_configData.proxyUrl;
    const style:String = layerObject.style;
    const useAMF:String = layerObject.useAMF;
    const useMapTime:Boolean = layerObject.useMapTime;
    const useProxy:Boolean = layerObject.useProxy;
   
    var i:int;
    switch (type.toLowerCase())
    {
     case "tiled":
     {
      var tiledLayer:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer(url);
      tiledLayer.alpha = alpha;
      tiledLayer.id = label;
      tiledLayer.name = label;
      tiledLayer.visible = visible;
      if (proxyUrl && useProxy)
      {
       tiledLayer.proxyURL = proxyUrl;
      }
      layerObject.layer = tiledLayer;
      tiledLayer.addEventListener(LayerEvent.LOAD_ERROR, layer_loadErrorEvent);
      tiledLayer.addEventListener(LayerEvent.LOAD, layer_loadEvent);
      map.addLayer(tiledLayer);
      break;
     }
     case "dynamic":
     {
      if (name == EFauna_Database)
      {
       params=getURLParameters();
      
       if (params["sciname"])
       {
        var scinameString:String = String(params.sciname);
        var Mypattern:RegExp = /%20/g;
        var sciString:String = scinameString.replace(Mypattern, " ");
       }
       if (params["synonyms"])
       {
        var synonymString:String = String(params.synonyms);
   
        var Mypattern1:RegExp = /%20/g;
        var synString:String = synonymString.replace(Mypattern1, " ");
        var Mypattern3:RegExp = /subsp/g;
        var synString2:String = synString.replace(Mypattern3, "ssp");
       }
       if (params["commonname"]) // don't use the commonname for searchs -- just to display
       {
        var commonString:String = String(params.commonname);
        var Mypattern2:RegExp = /%20/g;
        var nameString:String = commonString.replace(Mypattern2, " ");
       }
       if (params["BCStatus"])
       {
        var redblueString:String = String(params.BCStatus);
       }
      
       if (params["sciname"])
       {
        if (params["synonyms"])
        {
         queryExp0 = "Sciname IN (\'" + sciString + "\', "  + synString2 + " ) ";
        
        }
        else
        {
         // queryExp0 = "Sciname LIKE " + "\'" + sciString + "%\' " ;
         queryExp0 = "Sciname = " + "\'" + sciString + "\' " ;
        
        }
       }
       else
       {
        queryExp0 = "Sciname=\'\'";
       }
      
       /* The following section specifies the appropriate number of
       layers in each map service */
      
       var dynlayerdef:Array = new Array();
      
       if (label == "Freshwater mussels"){
        for (i = 0; i < 2; i++)
        {
         dynlayerdef.push(queryExp0);
        }
       }
       else if (label == "Herps"){
        for (i = 0; i < 4; i++)
        {
         dynlayerdef.push(queryExp0);
        }
       }
       else if (label == "Landsnails"){......
                                     
                                                        var dynlayer:ArcGISDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(url);
       dynlayer.id = label;
       dynlayer.name = label;
       dynlayer.automationName = name;
       dynlayer.visible = visible;
       dynlayer.alpha = alpha;
       dynlayer.layerDefinitions = dynlayerdef;
       map.addLayer(dynlayer);

==================================================================================================
I have started the code to get increment the http request however; I am getting a little confused!
This is what I have added so far?  I am a little confused on the placement of both for-loops as well as, the second definition of within the for loop. i.e. (urlRequest = 0; urlRequest< what?; ++)

Below is my additions:
====================================================================================
case "dynamic":
     {
     
      /*Attempting to solve url length limits*/
      var urlService:HTTPService = new HTTPService();
      urlService.url = "http://142.103.209.55/ArcGIS/rest/services/freshwatermussels/MapServer";
      urlService.method = "POST"

     
      if (name == EFauna_Database)
      {
       params=getURLParameters();
      /* 
       var urlReq:int; 
       for(urlReq = 0; urlReq < ?; urlReq++){} *
/
      
        if (params["sciname"])
        {
         var scinameString:String = String(params.sciname);
         var Mypattern:RegExp = /%20/g;
         var sciString:String = scinameString.replace(Mypattern, " ");
        // urlService.send(sciString);
        //  urlReq++;

        
        }
        if (params["synonyms"])
        {
         var synonymString:String = String(params.synonyms);
        
         var Mypattern1:RegExp = /%20/g;
         var synString:String = synonymString.replace(Mypattern1, " ");
//         urlService.send(synString);
//         urlReq++;

        
         var Mypattern3:RegExp = /subsp/g;
         var synString2:String = synString.replace(Mypattern3, "ssp");
//         urlService.send(synString2);
//         urlReq++;

        
        }
        if (params["commonname"]) // don't use the commonname for searchs -- just to display
        {
         var commonString:String = String(params.commonname);
         var Mypattern2:RegExp = /%20/g;
         var nameString:String = commonString.replace(Mypattern2, " ");
        }
        if (params["BCStatus"])
        {
         var redblueString:String = String(params.BCStatus);
//        urlService.send(redblueString);
//         urlReq++;

        }
       
        if (params["sciname"])
        {
         if (params["synonyms"])
         {
          queryExp0 = "Sciname IN (\'" + sciString + "\', "  + synString2 + " ) "; 
         
         }
         else
         {
          // queryExp0 = "Sciname LIKE " + "\'" + sciString + "%\' " ;
          queryExp0 = "Sciname = " + "\'" + sciString + "\' " ;
         
         }
        }
        else
        {
         queryExp0 = "Sciname=\'\'";
        }.......
=====================================================================================================
Again, not quite sure the positioning for these counter loops!
0 Kudos
sapnas
by
Occasional Contributor III
If I have understood right the url size limitation is when the user searches for the html page with the parameters. if so, are you programmatically adding the parameters to the html page URL? To query dynamic map service, use querytask(Flex api). Refer below link for sample code

http://help.arcgis.com/en/webapi/flex/samples/index.html#/Query_result_on_Map/01nq0000003q000000/
0 Kudos
ChristinaLaurier
New Contributor III
The url length limit is ok on the species atlas page (.html), on this page there is a link to the interactive map.

When the user selects the link to open the map, the parameters from the atlas page are passed; however, a shortened synonym string is used because we run into the length limits.

We have debated about trying to use a query; although, it may be redundant to have the user search for an atlas page; open the interactive map and then have to query the map a second time for the species information.

You can look at an example of the existing application (using API v1.3); we are currently updating this to a viewer2.5 project and trying to solve some of these existing issues.

http://linnet.geog.ubc.ca/Atlas/Atlas.aspx?sciname=Arenaria%20longipedunculata&redblue=R&lifeform=7
(on the above atlas page, there is a link to the interactive map below the map)
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Christina,

   I would consider assigning a numerical value to each species and use that in the URL search.
0 Kudos
sapnas
by
Occasional Contributor III
Now I get it, So you are basically passing parameters from asp.net web application to flash web application. How is the link in asp.net page is constructing these parameters? Is it retrieving the data for the parameters from the database? Are these two applications hosted on the same server?
0 Kudos
ChristinaLaurier
New Contributor III
Thanks for the suggestion Rob,
I will have to make sure to discuss that option with my supervisor!

Swapna,
From my understanding the data is retrieved from published map services.

For instance, the service below has 10 layers (the common attribute between all layers is Sciname)
http://142.103.209.55/ArcGIS/rest/services/VascularWMS/MapServer
0 Kudos
sapnas
by
Occasional Contributor III
Christina,

The parameters are created by asp.net page. asp.net page passes the url along with the parameters to the flex application. The parameters are truncated during the communication between asp.net and flex. Is "Click here to view the full interactive map and legend " link of asp.net page (http://linnet.geog.ubc.ca/Atlas/Atlas.aspx?sciname=Arenaria longipedunculata&redblue=R&lifeform=7) using mapservice?
0 Kudos