Incorporating Secured REST Services

1296
26
Jump to solution
05-10-2013 06:36 AM
KennethLyons
New Contributor
I'm having an issue with incorporating a REST Service that requires a username/password in order to view.  I've attempted to use the "Generate Token" option and that has worked for me in the past, however, I'm having no luck this time around. 

Is there something that I'm missing when inputting the code?  below is the URL with token that was generated from the site.

url="https://www.oagisargissvr.beta.state.pa.us/ArcGIS/rest/services/DMVA_SAFER_AVL/MapServer/1?token=UW1....">

I've tried several variations of this (http/https, with/without "1?" before "token")  even generated tokens for each variation.  I must be missing something because this wasn't that difficult in the past. 

thanks in advance for your assistance.
Tags (2)
0 Kudos
26 Replies
KennethLyons
New Contributor
Rob,

Yes I have been working in FlashBuilder on the source code this whole time.

Please let me know what I need to do.

Thanks
0 Kudos
KennethLyons
New Contributor
Rob,

As far the popups, I verified that all the fields are accurate.  However, when I click on them, the window does not open.  Is this an issue again with the server being 9.3?  or does it have to deal with the fact that its secure?

Thanks again.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ken,

   As far as the popups I believe the issue is that you have the popupconfig as a child tag of the layer tag and it is suppose to be an attribute of the layer tag.

            <layer label="Fires" type="feature" visible="false" alpha="1.0"                    popupconfig="popups/PopUp_Fires.xml"                    url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0"/>
0 Kudos
KennethLyons
New Contributor
Rob,

That did the trick for the popups. 

Thanks!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ken,

  In the MapManager.mxml find the addLayerToMap function and make the indicated changes:

                    case "feature":
                    {
                        var featureLayer:FeatureLayer = new FeatureLayer(url);
                        featureLayer.addEventListener(FlexEvent.HIDE, featureLayer_hideHandler);
                        featureLayer.alpha = alpha;
                        featureLayer.id = label;
                        featureLayer.name = label;
                        featureLayer.maxAllowableOffset = maxAllowableOffset;
                        featureLayer.outFields = [ '*' ]; // TODO: be smarter
                        featureLayer.token = token;
                        featureLayer.visible = visible;
                        featureLayer.useMapTime = useMapTime;
                        featureLayer.clusterer = clusterer;
                        if (useAMF)
                        {
                            featureLayer.useAMF = (useAMF == "true");
                        }
                        if (mode)
                        {
                            featureLayer.mode = mode;
                        }
                        if (definitionExpression)
                        {
                            featureLayer.definitionExpression = definitionExpression;
                        }
                        if (proxyUrl && useProxy)
                        {
                            featureLayer.proxyURL = proxyUrl;
                        }
                        // example for hard-coding layer symbology, e.g. for pre-10.0 ArcGIS Servers
                        /* if (label == "Traffic Cameras") // the layer label in main configuration file
                        {
                            var picSymbol:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/i_camera.png",30,30,0,0,0);
                            var rend:Renderer = new SimpleRenderer(picSymbol);
                            featureLayer.renderer = rend;
                        } */
//Added Code
                        if(label == "DMVA Inactive"){
                            var picSymbol:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/excel.png",30,30,0,0,0);
                            var picSymbol2:PictureMarkerSymbol = new PictureMarkerSymbol("assets/images/ru.png",30,30,0,0,0);
                            var infoArr:Array = [];
                            var uvVal1:UniqueValueInfo = new UniqueValueInfo(picSymbol,"HMV");
                            infoArr.push(uvVal1);
                            var uvVal2:UniqueValueInfo = new UniqueValueInfo(picSymbol,"Transport");
                            infoArr.push(uvVal1);
                            var uvRend:UniqueValueRenderer = new UniqueValueRenderer("TYPE",null,infoArr);
                            featureLayer.renderer = uvRend;
                        }
//End Added Code
                        layerObject.layer = featureLayer;
                        featureLayer.addEventListener(LayerEvent.LOAD_ERROR, layer_loadErrorEvent);
                        featureLayer.addEventListener(LayerEvent.LOAD, layer_loadEvent);
                        map.addLayer(featureLayer);
                        break;
                    }


Also at the top of the MapManager.mxml you need to ensure you have these two imports:

import com.esri.ags.renderers.UniqueValueRenderer;
            import com.esri.ags.renderers.supportClasses.UniqueValueInfo;


So far you have promoted most of my posts on this thread but have not marked it as answered. In case you are not sure how to do this look at this graphic:

0 Kudos
KennethLyons
New Contributor
var uvVal1:UniqueValueInfo = new UniqueValueInfo(picSymbol,"HMV");
                            infoArr.push(uvVal1);
                            var uvVal2:UniqueValueInfo = new UniqueValueInfo(picSymbol,"Transport");
                            infoArr.push(uvVal1);



Should the "picSymobol" for Transport read "picSymbol2"  as to identify a separate icon for a different value?

Ultimately I'm just not sure how to assign separate icons to different values in the "TYPE" attribute.

Thanks
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Ken,

   Yes, Sorry it should have been "picSymbol2"
0 Kudos