Select to view content in your preferred language

legend dijit ans secure mapservices : jsapi 2.3

1220
12
06-01-2011 06:21 AM
Marie-GilSeptfonds
New Contributor
Hello,

My legendDijit works with my non securised mapservices.

But doesn't with my securised mapservices.

When I look the request with firebug the token argument isn't at the fine place in the url.
http://extranet.nimes.fr/website/extranet/AGS/geo_agglo21/php/proxy.php?http://extranet.nimes.fr/arcgis/rest/services/secure/PLU_ZONAGES/MapServer?token=xxxxxxxxxxxxxxxxxx/legend

Normally it should be
http://extranet.nimes.fr/website/extranet/AGS/geo_agglo21/php/proxy.php?http://extranet.nimes.fr/arcgis/rest/services/secure/PLU_ZONAGES/MapServer/legend?token=xxxxxxxxxxxxxxxxxx


Anybody has an idea ?
0 Kudos
12 Replies
JeffPace
MVP Alum
It looks like you are appending both the token value and the "/legend" value to the end of the url and they are happening in the wrong order. 

do you have a line like this in your proxy?

if(token != null) {
    reqUrl = reqUrl + (reqUrl.indexOf("?") > -1 ? "&" : "?") + "token=" + token;
  }

my guess is that you are appending the "/legend" after generating the proxy url, if you do it first you should be fine.
0 Kudos
Marie-GilSeptfonds
New Contributor
in my proxy.php i've this part of code
if ($token) {
    $targetPath .= (stripos($targetPath, "?") !== false ? '&' : '?').'token='.$token;
  }
0 Kudos
JeffPace
MVP Alum
Look at the $targetPath before and after that statement.  My guess is this is where the token is being inserted into the wrong location and you might need to modify that statement.
0 Kudos
Marie-GilSeptfonds
New Contributor
Indeed, I think the problem is here.

Thanx
0 Kudos
Marie-GilSeptfonds
New Contributor
I found a solution.

When the proxy.php test the token (if ($token) {...}) I add this part of code
if ($token) {
    if(stripos($parts[1], "/")){
      $targetUrl = str_replace('?token='.$token, "", $targetUrl, $count);
    }
    $targetUrl .= (stripos($targetUrl, "?") !== false ? '&' : '?').'token='.$token;
  }


Where $parts[1] is the result of $parts = preg_split("/\?/", $targetUrl);

In fact I test if the query contains a "/".
0 Kudos
AndrewBrown1
Occasional Contributor II
If I'm logged in using the token, I don't even see the that the Legend is available under REST. I can see the layers and everything else, but not the legend.

What gives?
0 Kudos
Marie-GilSeptfonds
New Contributor
Which AGS version do you have ?
0 Kudos
AndrewBrown1
Occasional Contributor II
At the time of writing, we were using 10.00, as I thought the server already had SP2 installed.

But while we were in REST services, I noticed it was 10, so we upgraded to 10.02, SP2.

Sp2 is now installed but the legend still isn't appearing. We cleared the cache and stopped/started the service, but nothing worked. Any ideas?
0 Kudos
Marie-GilSeptfonds
New Contributor
I'm in 10 sp1.
My REST console displays 10.01.

I've no other idea.
0 Kudos