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());
}
你打什麼樣的網絡服務(WCF,ASMX)? – 2012-01-16 00:52:23
我打電話asmx文件 – 2012-01-16 06:46:43
相關問題: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