How do I check if an Url string is valid as a layer?

1485
7
08-04-2011 12:39 AM
Labels (1)
linusang
New Contributor II
Given a arbitrary url string.. how do i know if the url is connected successfully and valid to be added to a map?

Thanks
0 Kudos
7 Replies
RichardWatson
Frequent Contributor
I am not sure that I understand your question.

When you publish a map service there is a URL for each layer.  The way the URL is generated is very deterministic and it includes several elements including the layer indice which is simply the 0 based index of the layer in the map.
0 Kudos
linusang
New Contributor II
i'm providing a way to allow users to enter any url and add to the map dynamically... i would like to know if the url the user entered is connected(server exists, connection exists,  internet connection available), is a valid ArcGIS Server layer, or a KML layer, or a WMS layer, etc.

i would like to verify the url before adding to the Map...

like a web browser.... when you type http://www.yahoo.com.. it is a valid link.. however it is not a valid ArcGIS Map layer......
0 Kudos
RichardWatson
Frequent Contributor
I think that you just have to call a REST method on that URL to confirm whether or not it is valid.  Look through all the methods available and pick one that makes sense.
0 Kudos
linusang
New Contributor II
do you have any links of information or source code that demonstrates that functionality?
0 Kudos
RichardWatson
Frequent Contributor
http://resources.arcgis.com/ is the place to start.
0 Kudos
linusang
New Contributor II
Hi, I'm using the HttpWebRequest class to check...

however, how do i know if the HttpWebResponse is a valid ArcGIS Server response?
0 Kudos
RichardWatson
Frequent Contributor
Send a request that asks for a response in JSON and see if you get back something valid.

If you don't understand this then play with it using the services directory.
0 Kudos