how to check if there is connection to my WebService?
i have Windows-mobile program that connect to my WebService.
how to check if there is connection fro开发者_开发问答m my Windows-mobile to my WebService ?
Except of using try
and catch
......
thanks in advance
There is no direct way to know if there is a connection to your webservice. Usually I would call a dummy operation in the webservice, or try get the wsdl from the webservice, all this wrapped on a try catch. Is there any reasons why you wouldn't want to use a try catch?
The problem is you'll never know if the service is available until you try. Assume you create a secondary service that tells you if the main one is running, then what happens if the secondary fails but not the primary?
And when you think about it, how do YOU check if it is running? You probably just try to browse the metadata address, don't you. Same goes for the mobile apps.
Generally speaking, every call to a service should be wrapped in a try/catch to avoid failing miserably.
You may also want to create a heartbeat operation on the service, it is used to check if the service is responding correctly. This is a common technique when monitoring services.
精彩评论