Multiple Mapservers

525
2
08-29-2011 12:37 AM
PercyJackson
New Contributor
Hi guys,

I have a folder in my REST service that contains multiple mapservers,
is there a way in Silverlight to count the mapservers in the folder?

Or is there any way to loop through the folder and give the names
of each of the mapservers?

Thanx
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
You can use ArcGISDynamicMapServiceLayer as in this sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SubLayerList. You don't have to add this in your map, as long as you call layer.Initialize(), Initialized event should fire and you can access its sub layers then.
0 Kudos
dotMorten_esri
Esri Notable Contributor
The above code only allows you to get the layers within one mapservice, but not to tell you what services are available in the entire rest catalog.
The API doesn't come with any classes for interrogating the services available at a REST endpoint out of the box. Luckily using DataContract and a WebClient it's pretty simple to write the code that does that type of webrequest.
See the following MSDN article on how to handle JSON in Silverlight: http://msdn.microsoft.com/en-us/library/cc197957(v=vs.95).aspx
Here's another blog post that covers this: http://timheuer.com/blog/archive/2008/05/06/use-json-data-in-silverlight.aspx

To get the JSON version of a REST catalog, simply append ?f=json to the Url (or ?f=pjson if you want it nicely formatted while developing this)
0 Kudos