2012-01-16 68 views
1

我使用WebServiceProxy.invoke來調用Web服務方法。我意識到其中一個參數是一個函數,用於處理方法拋出異常時發生的錯誤。當webservice方法拋出異常時如何獲取錯誤消息。

我試着用方法get_message()得到錯誤信息。這個工作 - 當我從localhost訪問它時。但是,當我從遠程計算機訪問該方法時,消息被標準錯誤更改:「處理請求時出錯」。並不意味着

callws = function (args) { 
    // call webservice to fill content panel 
    Sys.Net.WebServiceProxy.invoke(_servicePath, _serviceMethod, false, 
      { contextKey: args }, Function.createDelegate(this, onSubmitComplete), 
       Function.createDelegate(this, onSubmitError), args); 
    } 

onSubmitComplete = function (result, userContext, methodName) { 
    ... 
} 

onSubmitError = function (result, userContext, methodName) { 
    // note: this result.get_message() contain exception message when 
    // accessed from localhost, but contain "There was an error processing the request" 
    // when accessed from remote computer 
    alert(result.get_message()); 
} 
+0

你打什麼樣的網絡服務(WCF,ASMX)? – 2012-01-16 00:52:23

+0

我打電話asmx文件 – 2012-01-16 06:46:43

+1

相關問題:http://stackoverflow.com/questions/6438339/javascript-asmx-web-service-call-handling-exceptions,http://stackoverflow.com/questions/201095/how-do -i-handle-exceptions-thrown-by-asmx-services – 2012-01-16 13:26:46

回答

3

ASP.net運行時錯誤在部署環境中顯示給你的客戶,你的服務器是否配置正確不顯示在部署customErrors,如果你要調試的代碼,你可以設置在您的web.configoff之間的customErrorsmode標誌,或將其保留爲RemoteOnly並在服務器上正確調試代碼!

相關問題