Error handling using WCF with Javascript support?

Is there any documentation on how to use callback functions in a WCF service that is exposed to Javascript? I am interested in receiving information from FailureCallback on why my method does not work.

In other words, I have the following 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 to implement wcfFailCallback?

+3
source share
1 answer

I assume that you are using ASP.NET AJAX and not jQuery or some other third-party JavaScript library.

The ASP.NET AJAX failure callback accepts one parameter. From MSDN, the error callback will 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;
}

, wcfFailCallback error, , , .

MSDN . , WCF ASP.NET AJAX.

, ! , , .

+4

Source: https://habr.com/ru/post/1778172/


All Articles