2012-02-22 97 views
1

檢查Web服務是否啓動並啓動的最佳方法是什麼?vb.net Web服務活動連接測試

我意識到有很多不同的因素,但我想在發送數據之前做一些簡單的事情,比如在構建代理以查看服務是否能夠連接。我在vb.net編碼。

這種類型的通信是否還有最佳實踐?

+0

可能重複[我怎樣才能找出一個Web服務正在運行或不?( http://stackoverflow.com/questions/3170380/how-can-i-find-out-if-a-web-service-is-running-or-not) – 2012-02-22 15:33:33

回答

1

可能最簡單的方法是「ping」你的web服務,查詢一個簡單的方法,像當前版本。

示例(PowerShell中)來記錄當前版本(法版())到的應用程序事件日誌

$ApplicationEventLog = New-Object System.Diagnostics.EventLog('Application') 
$ApplicationEventLog.Source = "My Webservice Ping" 

try 
{ 
    $wsproxy = New-WebserviceProxy -uri "http://mywebservice:7777/MyService.svc?wsdl" 
    $message = "My Webservice Version is {0}" -f $wsproxy.Version() 
} 
catch [System.Exception] 
{ 
    $ApplicationEventLog.WriteEntry($_.Exception.ToString(), [System.Diagnostics.EventLogEntryType]::Error) 
} 

$ApplicationEventLog.WriteEntry($message,[System.Diagnostics.EventLogEntryType]::Information)