使用支持 Javascript 的 WCF 进行错误处理?

发布于 2024-10-05 21:33:14 字数 520 浏览 0 评论 0原文

是否有关于如何在公开给 Javascript 的 WCF 服务中使用回调函数的文档?我有兴趣从 FailureCallback 获取有关为什么我的方法未触发的信息。

换句话说,我有以下 JavaScript 代码:

     function getWCF_RowNumber(parentID) {
              logEvent("<strong>Busy</strong>: Please wait while lower grid is refreshed...");                  
              var service = new ajaxTest();
              service.Vendor_GetParentRowNumber(parentID, moveBottomGridToRow, wcfFailCallback, null);
          }

How do I Implement wcfFailCallback?

Is there documentation on how to use the callback functions in a WCF Service that is exposed to Javascript? I'm interested in getting information from the FailureCallback as to why my method isn't firing.

In other words I have the follwoing JavaScript code:

     function getWCF_RowNumber(parentID) {
              logEvent("<strong>Busy</strong>: Please wait while lower grid is refreshed...");                  
              var service = new ajaxTest();
              service.Vendor_GetParentRowNumber(parentID, moveBottomGridToRow, wcfFailCallback, null);
          }

How do I implement wcfFailCallback?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不交电费瞎发啥光 2024-10-12 21:33:14

我假设您使用的是 ASP.NET AJAX,而不是 jQuery 或其他第 3 方 JavaScript 库。

ASP.NET AJAX 失败回调采用单个参数。从 MSDN 来看,示例失败回调如下所示:

function wcfFailCallback(error)
{
    var stackTrace = error.get_stackTrace();
    var message = error.get_message();
    var statusCode = error.get_statusCode();
    var exceptionType = error.get_exceptionType();
    var timedout = error.get_timedOut();

    // Display the error.    
    var RsltElem = 
        document.getElementById("Results");
    RsltElem.innerHTML = 
        "Stack Trace: " +  stackTrace + "<br/>" +
        "Service Error: " + message + "<br/>" +
        "Status Code: " + statusCode + "<br/>" +
        "Exception Type: " + exceptionType + "<br/>" +
        "Timedout: " + timedout;
}

因此,wcfFailCallback 函数采用一个 error 参数,该参数具有许多属性,可为您提供有关失败原因的信息。

MSDN 上的完整文章位于此处。它详细介绍了如何将 WCF 服务连接到 ASP.NET AJAX 客户端。

我希望这有帮助!如果还有其他问题或者我没有完全理解您的问题,请告诉我,我会相应地更新我的答案。

I'm assuming you're using ASP.NET AJAX and not jQuery or some other 3rd party JavaScript library.

The ASP.NET AJAX failure callback takes a single parameter. From MSDN, a sample failure callback would look like this:

function wcfFailCallback(error)
{
    var stackTrace = error.get_stackTrace();
    var message = error.get_message();
    var statusCode = error.get_statusCode();
    var exceptionType = error.get_exceptionType();
    var timedout = error.get_timedOut();

    // Display the error.    
    var RsltElem = 
        document.getElementById("Results");
    RsltElem.innerHTML = 
        "Stack Trace: " +  stackTrace + "<br/>" +
        "Service Error: " + message + "<br/>" +
        "Status Code: " + statusCode + "<br/>" +
        "Exception Type: " + exceptionType + "<br/>" +
        "Timedout: " + timedout;
}

So the wcfFailCallback function takes an error parameter, which has a number of properties that provide you information about what failed.

The full article on MSDN is here. It goes into some decent amount of details about how to hook up WCF services to ASP.NET AJAX clients.

I hope this helps!! If there are other questions or if I didn't fully understand your question, let me know and I'll update my answer accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文