문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top