Select to view content in your preferred language

connecting to any arcgis server dynamically

2041
13
05-30-2012 01:09 AM
shaziyashaikh
Emerging Contributor
Hi,

Given any arcgis server url, i want to fetch all its services in the list box.
When i click on any layer from the list box, that layer should be displayed on my map

can anyone pls tell me how to dynamically fetch all services of any arcgis server.

thanks
0 Kudos
13 Replies
shaziyashaikh
Emerging Contributor
I debugged the code , and found that string is
    e.Result "{\"currentVersion\":10.01,\"serviceDescription\":\"This map is in \\u003ca href=\\\"http://links.esri.com/agol_lifecycle \\\" target=\\\"_new\\\"\\u003eExtended Support\\u003c/a\\u003e and is no longer updated. Esri recommends that you use \\u003ca href=\\\"http://goto.arcgisonline.com/maps/World_Street_Map \\\" target=\\\"_new\\\"\\u003eWorld_Street_Map\\u003c/a\\u003e instead (ArcGIS 9.3 or higher is required).\",\"mapName\":\"Layers\",\"description\":\"This worldwide street map presents highway-level data for the world and street-level data for the United States, Canada, Japan, Southern Africa, and a number of countries in Europe and elsewhere. This comprehensive street map includes highways, major roads, minor roads, railways, water features, administrative boundaries, cities, parks, and landmarks, overlaid on shaded relief imagery for added context. The street map was developed by Esri using DeLorme data and TomTom street data for North America and Europe. Coverage for street-level data in Europe includes Andorra, Austria, Belgium, Czech Republic, Denmark, France, Germany, Great Britain, Greece, Hungary, Ireland, Italy, Luxembourg, Netherlands, Northern Ireland (Belfast only), Norway, Poland, Portugal, San Marino, Slovakia, Spain, Sweden, and Switzerland. Coverage for street-level data elsewhere in the world includes China (Hong Kong only), Indonesia (Jakarta only), Egypt (Cairo only), Japan, Mexico (Mexico City only), Russia (Moscow, St. Petersburg only), and Turkey (Istanbul, Ankara only). For more information on this map, visit us online at http://goto.arcgisonline.com/maps/ESRI_StreetMap_World_2D\",\"copyrightText\":\"Sources: Esri, DeLorme, TomTom, USGS, Esri Japan, Esri China (Hong Kong)\",\"layers\":[{\"id\":0,\"name\":\"World Street Map\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0}],\"tables\":[],\"spatialReference\":{\"wkid\":4326},\"singleFusedMapCache\":true,\"tileInfo\":{\"rows\":512,\"cols\":512,\"dpi\":96,\"format\":\"JPEG\",\"compressionQuality\":90,\"origin\":{\"x\":-180,\"y\":90},\"spatialReference\":{\"wkid\":4326},\"lods\":[{\"level\":0,\"resolution\":0.3515625,\"scale\":147748799.285417},{\"level\":1,\"resolution\":0.17578125,\"scale\":73874399.6427087},{\"level\":2,\"resolution\":0.087890625,\"scale\":36937199.8213544},{\"level\":3,\"resolution\":0.0439453125,\"scale\":18468599.9106772},{\"level\":4,\"resolution\":0.02197265625,\"scale\":9234299.95533859},{\"level\":5,\"resolution\":0.010986328125,\"scale\":4617149.97766929},{\"level\":6,\"resolution\":0.0054931640625,\"scale\":2308574.98883465},{\"level\":7,\"resolution\":0.00274658203125,\"scale\":1154287.49441732},{\"level\":8,\"resolution\":0.001373291015625,\"scale\":577143.747208662},{\"level\":9,\"resolution\":0.0006866455078125,\"scale\":288571.873604331},{\"level\":10,\"resolution\":0.00034332275390625,\"scale\":144285.936802165},{\"level\":11,\"resolution\":0.000171661376953125,\"scale\":72142.9684010827},{\"level\":12,\"resolution\":8.58306884765629E-05,\"scale\":36071.4842005414},{\"level\":13,\"resolution\":4.29153442382814E-05,\"scale\":18035.7421002707},{\"level\":14,\"resolution\":2.14576721191407E-05,\"scale\":9017.87105013534},{\"level\":15,\"resolution\":1.07288360595703E-05,\"scale\":4508.93552506767}]},\"initialExtent\":{\"xmin\":-199.999992538573,\"ymin\":-199.999992538573,\"xmax\":199.999992538573,\"ymax\":199.999992538573,\"spatialReference\":{\"wkid\":4326}},\"fullExtent\":{\"xmin\":-179.99999,\"ymin\":-89.99999,\"xmax\":179.99999,\"ymax\":89.99999,\"spatialReference\":{\"wkid\":4326}},\"units\":\"esriDecimalDegrees\",\"supportedImageFormatTypes\":\"PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI,BMP\",\"documentInfo\":{\"Title\":\"World Street Map\",\"Author\":\"Esri\",\"Comments\":\"\",\"Subject\":\"streets, highways, major roads, minor roads, railways, water features, administrative boundaries, cities, parks, protected areas, landmarks\",\"Category\":\"transportation(Transportation Networks)\",\"Keywords\":\"World, Global, Canada, Europe, Japan, North America, Southern Africa, United States, 2008\",\"Credits\":\"\"},\"capabilities\":\"Map\"}" string


if u C e.Result it has the above string
string json = e.Result;
            Byte[] bytes = Encoding.Unicode.GetBytes(json);
            MemoryStream memoryStream = new MemoryStream(bytes);

what is wrong at line 1 position1.
error msg is at line 1 pos1

thanks
0 Kudos
shaziyashaikh
Emerging Contributor
Can anyone tell me what is the main difference btw DataContractJsonSerializer and DataContractSerializer
If i use DataContractJsonSerializer, VS gives compiler error as missing library System.Runtime.Serialization.JSon.
Which i guess it is available only in .NET framework 4

what is the alternative to this

Thanks
0 Kudos
DominiqueBroux
Esri Frequent Contributor
DataContractSerializer is for XML stream, DataContractJsonSerializer is for Json.

If you use DataContractSerializer, that explains for sure the error you got:)

With SL, DataContractJsonSerializer is available by referencing System.ServiceModel.Web
0 Kudos
shaziyashaikh
Emerging Contributor
Ok

Thank you very much
0 Kudos