+ Reply to Thread
Results 1 to 4 of 4

Thread: Crossdomain.xml violation from DynamicLegendWidget

  1. #1
    Steven Haslemore
    Join Date
    May 2010
    Posts
    61
    Points
    2
    Answers Provided
    2


    0

    Default Crossdomain.xml violation from DynamicLegendWidget

    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

  2. #2
    Robert Scheitlin

    Join Date
    Mar 2010
    Posts
    9,260
    Points
    5579
    Answers Provided
    938


    0
    This post is marked as the answer

    Lightbulb Re: Crossdomain.xml violation from DynamicLegendWidget

    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.
    Just because it's not the answer you want, does not mean that it is not the answer.

    Robert Scheitlin

    GIS Manager
    Calhoun County, Alabama


  3. #3
    Steven Haslemore
    Join Date
    May 2010
    Posts
    61
    Points
    2
    Answers Provided
    2


    0

    Default Re: Crossdomain.xml violation from DynamicLegendWidget

    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

    Code:
    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);
    		}
    	}
    }
    Last edited by StevenHas; 05-11-2012 at 09:16 AM.

  4. #4
    Steven Haslemore
    Join Date
    May 2010
    Posts
    61
    Points
    2
    Answers Provided
    2


    1

    Default Re: Crossdomain.xml violation from DynamicLegendWidget

    Opps, that broke it for non secure services, the proxyURL will be null, not empty string.

    Code:
    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);
            }
        }
    }

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts