3 Replies Latest reply on May 14, 2012 1:57 PM by StevenHas

    Crossdomain.xml violation from DynamicLegendWidget

    StevenHas
      Hi there,

      I've just applied SP4 and am having issues with the dynamic legend widget.

      I'm getting a Security Sandbox Violation for my secure service.
      The legend is working fine for unsecured dynamic services.

      The service is secured via a proxy with windows authentication against it adding the token.
      I'm running 2.3 flexviewer with some customization.

      The service is behaving fine in all other regards.

      Any thoughts appreciated.

      Cheers,
      Steven
        • Re: Crossdomain.xml violation from DynamicLegendWidget
          rscheitlin
          Steven,

             I am sure it has something to do with the fact that the widget is not developed to work with secure services. I don't use secure services and thus have not developed my widgets to because I don't have access to a secure service to test against. I will add it to my todo list when some free time becomes available as I was made aware of an esri host secure service I can use for testing when I was a the Developer Summit in March.
          • Re: Crossdomain.xml violation from DynamicLegendWidget
            StevenHas
            Hi Robert,

            you're quite right, the proxy wasn't being prefixed to the requests.

            I've added code in registerMapLayer to add the proxy and it is behaving now.
            NB. Have not tested on tiled or feature services.

            We had not applied any of the service packs so were on version 10.00, so it was previously using the getAllDetailsResult function.

            I'm not sure why it was presenting as a crossdomain rather than an invalid token as the domain should have been good, but working now.

            Thanks for all the public work you put out here for us.

            Steven



            private function registerMapLayer(layer:*):void
            {
            var httpServ:HTTPService = new HTTPService();
            var lname:String
            if (layer is ArcGISTiledMapServiceLayer)
            {
              if(layer.version >= 10.01)
              {
               if (ArcGISTiledMapServiceLayer(layer).proxyURL != ""){
                httpServ.url = ArcGISTiledMapServiceLayer(layer).proxyURL + "?" + ArcGISTiledMapServiceLayer(layer).url + "/legend?f=json";
               }else{
                httpServ.url = ArcGISTiledMapServiceLayer(layer).url + "/legend?f=json";
               }
               httpServ.resultFormat = "text";
               lname = ArcGISTiledMapServiceLayer(layer).id;
               httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname)});
               httpServ.send();
              }else{
               lname = ArcGISTiledMapServiceLayer(layer).id;
               ArcGISTiledMapServiceLayer(layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)});
               ArcGISTiledMapServiceLayer(layer).getAllDetails();
              }
            }
            else if (layer is ArcGISDynamicMapServiceLayer)
            {
              if(layer.version >= 10.01)
              {
               if (ArcGISDynamicMapServiceLayer(layer).proxyURL != ""){
                httpServ.url = ArcGISDynamicMapServiceLayer(layer).proxyURL + "?" + ArcGISDynamicMapServiceLayer(layer).url + "/legend?f=json";
               }else{
                httpServ.url = ArcGISDynamicMapServiceLayer(layer).url + "/legend?f=json";
               }
               httpServ.resultFormat = "text";
               lname = ArcGISDynamicMapServiceLayer(layer).id;
               httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname)});
               httpServ.send();
              }else{
               lname = ArcGISDynamicMapServiceLayer(layer).id;
               ArcGISDynamicMapServiceLayer(layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)});
               ArcGISDynamicMapServiceLayer(layer).getAllDetails();
              }
            }
            else if (layer is FeatureLayer)
            {
              var FeatServId:Number = Number.NaN;
              var msName:String;
              if (FeatureLayer(layer).proxyURL != ""){
               msName = FeatureLayer(layer).proxyURL + "?" + FeatureLayer(layer).url.replace("FeatureServer","MapServer");
              }else{
               msName = FeatureLayer(layer).url.replace("FeatureServer","MapServer");
              }
              var x:String = msName.substring(msName.length - 9);
              if(msName.substring(msName.length - 9) != "MapServer")
              {
               httpServ.url = msName.substring(0,msName.lastIndexOf("/")) + "/legend?f=json";
               FeatServId = parseInt(msName.substring(msName.lastIndexOf("/")+ 1));
              }else{
               httpServ.url = msName + "/legend?f=json";
              }
              if(layer.layerDetails.version >= 10.01)
              {
               httpServ.resultFormat = "text";
               lname = FeatureLayer(layer).id;
               httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,FeatServId)});
               httpServ.send();
              } else {
               lname = FeatureLayer(layer).id;
               getFeatureResult(FeatureLayer(layer).layerDetails,lname);
              }
            }
            }

            • Re: Crossdomain.xml violation from DynamicLegendWidget
              StevenHas
              Opps, that broke it for non secure services, the proxyURL will be null, not empty string.

              private function registerMapLayer(layer:*):void
              {
                  var httpServ:HTTPService = new HTTPService();
                  var lname:String
                  if (layer is ArcGISTiledMapServiceLayer)
                  {
                      if(layer.version >= 10.01)
                      {
                          if (ArcGISTiledMapServiceLayer(layer).proxyURL){
                              httpServ.url = ArcGISTiledMapServiceLayer(layer).proxyURL + "?" + ArcGISTiledMapServiceLayer(layer).url + "/legend?f=json";
                          }else{
                              httpServ.url = ArcGISTiledMapServiceLayer(layer).url + "/legend?f=json";    
                          }
                          httpServ.resultFormat = "text";
                          lname = ArcGISTiledMapServiceLayer(layer).id;
                          httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname)});
                          httpServ.send();
                      }else{
                          lname = ArcGISTiledMapServiceLayer(layer).id;
                          ArcGISTiledMapServiceLayer(layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)});
                          ArcGISTiledMapServiceLayer(layer).getAllDetails();
                      }
                  }
                  else if (layer is ArcGISDynamicMapServiceLayer)
                  {
                      if(layer.version >= 10.01)
                      {
                          if (ArcGISDynamicMapServiceLayer(layer).proxyURL){
                              httpServ.url = ArcGISDynamicMapServiceLayer(layer).proxyURL + "?" + ArcGISDynamicMapServiceLayer(layer).url + "/legend?f=json";
                          }else{
                              httpServ.url = ArcGISDynamicMapServiceLayer(layer).url + "/legend?f=json";    
                          }
                          httpServ.resultFormat = "text";
                          lname = ArcGISDynamicMapServiceLayer(layer).id;
                          httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname)});
                          httpServ.send();
                      }else{
                          lname = ArcGISDynamicMapServiceLayer(layer).id;
                          ArcGISDynamicMapServiceLayer(layer).addEventListener(DetailsEvent.GET_ALL_DETAILS_COMPLETE,function(event:DetailsEvent):void{getAllDetailsResult(event,lname)});
                          ArcGISDynamicMapServiceLayer(layer).getAllDetails();
                      }
                  }
                  else if (layer is FeatureLayer)
                  {
                      var FeatServId:Number = Number.NaN;
                      var msName:String;
                      if (FeatureLayer(layer).proxyURL){
                          msName = FeatureLayer(layer).proxyURL + "?" + FeatureLayer(layer).url.replace("FeatureServer","MapServer");
                      }else{
                          msName = FeatureLayer(layer).url.replace("FeatureServer","MapServer");    
                      }
                      var x:String = msName.substring(msName.length - 9);
                      if(msName.substring(msName.length - 9) != "MapServer")
                      {
                          httpServ.url = msName.substring(0,msName.lastIndexOf("/")) + "/legend?f=json";
                          FeatServId = parseInt(msName.substring(msName.lastIndexOf("/")+ 1));
                      }else{
                          httpServ.url = msName + "/legend?f=json";
                      }
                      if(layer.layerDetails.version >= 10.01)
                      {
                          httpServ.resultFormat = "text";
                          lname = FeatureLayer(layer).id;
                          httpServ.addEventListener(ResultEvent.RESULT,function(event:ResultEvent):void{processLegend(event,lname,FeatServId)});
                          httpServ.send();
                      } else {
                          lname = FeatureLayer(layer).id;
                          getFeatureResult(FeatureLayer(layer).layerDetails,lname);
                      }
                  }
              }