Select to view content in your preferred language

checking if a service is availible

880
4
10-25-2010 06:47 AM
GavinTrowles
Emerging Contributor
Hi

Is there anyway to detect if a service is available to avoid having the map wait for a service that may never respond. On occasion the service that my code points to has been known to not respond to my request and in these instances I would like to report this issue to the user.

Thanks
0 Kudos
4 Replies
RichardWatson
Deactivated User
Perhaps you could develop a web service which uses the SOM in order to ascertain information with regards to the services?
0 Kudos
HemingZhu
Frequent Contributor
Hi

Is there anyway to detect if a service is available to avoid having the map wait for a service that may never respond. On occasion the service that my code points to has been known to not respond to my request and in these instances I would like to report this issue to the user.

Thanks


Have you tried to use onLayerAddResult(layer, error). by testing if error ==null, you will know if the layer add successfully.
0 Kudos
ScottMoore__Olympia_
Esri Contributor
Here is a sample I threw together to test whether or not a dynamic map service was available or not.  You should use the Firebug console or something like that to see what is happening.  This checks to see if the layer has loaded with triggers to let a user know that the layer is taking time to load.  Also, it will detect if the layer has loaded and there are intermittent problems with the layer getting images from the server.  Hope this helps.

http://nwdemo1.esri.com/js/various/testLayerLoad2.htm
0 Kudos
RichardWatson
Deactivated User
We use SilverLight and what we do is as follows:

1) For layers we use that are required, i.e. the application will not function without it, we add an attached property to the XAML that indicates that the layer is required
2) In the application unhandled exception handler, we check to see if the exception is related to a layer load issue
3) If the exception relates to a layer load issue and the layer is required then we fail the application and inform the user
4) If the exception relates to a layer load issue and the layer is not required then we eat the exception and simply log the error
0 Kudos