AJAX Web Services: The server method '....' failed.

Last post 09-19-2008 9:40 AM by DJA01. 2 replies.

Sort Posts:

  • AJAX Web Services: The server method '....' failed.

    09-18-2008, 10:27 AM
    • Member
      1 point Member
    • DJA01
    • Member since 02-01-2008, 12:00 PM
    • Posts 15

     I have a Web Application that uses ASP.NET AJAX Web Services to asynchroniously call a Web Service to update a Database (amongst other things).  My Application will call the Web Service at various points while the user is at a specific page (for example, whenever they press a Button to save changes).  Every time it works perfectly fine.  However, if I visit the page with FireFox (Version 3) and press the "Next Page" Button which causes a Postback to direct the user to the next page the Web Service will always display the error message below.  The Web Service itself however is in fact working given that I can see the data being updated in the Database.  Nevertheless FireFox still calls the "Failed" function.

     Any idea why this might be the case?  The code below should help provide some insight as to whats going on.

     Thanks.



    Error Code:
    The server method 'setData' failed.
    Status Code: 0
    Timed Out: false


    JavaScript Functions:
    function saveData()
    {
    // Note that "proxyObject" is specified earlier.  It is a JavaScript Array / .NET Collection of type "CustomData".
            WebServiceObject.setData(proxyObject.lstData, successSet, failedSet);
    }

    function failedSet(error)
    {
        alert("Stack Trace: " + error.get_stackTrace() + "  -  Error: " + error.get_message() + "  -  Status Code: " + error.get_statusCode() + "  -  Exception Type: " + error.get_exceptionType() + "  -  Timed Out: " + error.get_timedOut());
    }


    Script Manager Code:
            <asp:ScriptManager runat="server" ID="ScriptManager1">
              <Services>
                <asp:ServiceReference path="DataSaver.asmx" />
              </Services>
            </asp:ScriptManager>


    DataSaver.asmx Code:
    <%@ WebService Language="VB" CodeBehind="~/App_Code/WebServiceObject.vb" Class="WebServiceObject" %>


    WebServiceObject.vb Code:

    Imports System.Web
    Imports System.Web.Services
    Imports System.Xml
    Imports System.Web.Services.Protocols
    Imports System.Web.Script.Services
    Imports System.Data.SqlClient
    Imports System.IO

    Imports DataTracking    ' Custom Class.  Contains Class "CustomData".

    ' The Class below contains the Web Service methods for saving data in the Database.
    ' This is necessary in order to allow Silverlight to communicate between the Client and the Server.
    <WebService(Namespace:="http://tempuri.org/")> _
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ScriptService()> _
    <GenerateScriptType(GetType(CustomData))> _
    Public Class WebServiceObject
        Inherits System.Web.Services.WebService

        <WebMethod(EnableSession:=True)> _
        Public Function setData(ByVal newData As Collections.Generic.List(Of CustomData)) As Boolean
                ' Updates data in the Database.
        End Function

    End Class

     

  • Re: AJAX Web Services: The server method '....' failed.

    09-18-2008, 4:32 PM
    • Member
      1 point Member
    • DJA01
    • Member since 02-01-2008, 12:00 PM
    • Posts 15

     Could the problem be partially related to the fact that the "Next" Button is causing a full Postback AND an Async Postback?  This however would still not explain why it works in Internet Explorer but not FireFox (and potentially other browsers I would presume).

    Any help is appreciated.  Thanks.

  • Re: AJAX Web Services: The server method '....' failed.

    09-19-2008, 9:40 AM
    Answer
    • Member
      1 point Member
    • DJA01
    • Member since 02-01-2008, 12:00 PM
    • Posts 15

     I have found the solution to the problem.  The problem was due to the Web Service being called Asynchronously and then a full Postback occuring at the same time.  I changed the ASP:Button to an HTML input type="button" and now its a success each time even in FireFox.

Page 1 of 1 (3 items)