views:

115

answers:

0

Hello,

I'm having WCF problems where I'm receiving errors that a token 'false' was expected but found 'filen', which is because I have a ajax function written in jQuery that is sending JSON in the form of "filename:Bank Detail SPC 09-0724 to 09-0824".

I dont see any reason why its looking for false...I have been banging my head on this for the past couple of weeks off & on. I have included the Error, jQuery function, and the service. Please someone tell me what obvious blaring omission that's too obvious for me to see... ;-)

Thanks for any and all help!!!

Error Message in the event viewer:

Exception: System.Xml.XmlException: The token 'false' was expected but found 'filen'.at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader,String res, String arg1, String arg2, String arg3) at System.Xml.XmlExceptionHelper.ThrowTokenExpected(XmlDictionaryReader reader, String expected, String found) at System.Runtime.Serialization.Json.XmlJsonReader.Read() at System.Xml.XmlDictionaryWriter.WriteNode(XmlDictionaryReader reader, Boolean defattr)at System.ServiceModel.Channels.BufferedMessage.OnBodyToString(XmlDictionaryWriter writer) at System.ServiceModel.Channels.Message.ToString(XmlDictionaryWriter writer) at System.ServiceModel.Diagnostics.MessageLogTraceRecord.WriteTo(XmlWriter writer) at System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLogTraceRecord record) at System.ServiceModel.Diagnostics.MessageLogger.LogMessageImpl(Message& message, XmlReader reader, MessageLoggingSource source) at System.ServiceModel.Diagnostics.MessageLogger.LogMessage(Message& message, XmlReader reader, MessageLoggingSource source) Process Name: w3wp Process ID: 864

Calling Function: $(document).ready(function() {

    $('#btnFile').click(function(e) {
    var b = "Bank Detail SPC 09-0724 to 09-0824";
    var d = '';
    d = 'filename' + ':' + b;


    $.ajax({
        type: "POST",
        url: "AjaxWcf.svc/SeeFile",
        contentType: "application/json; charset=utf-8",
        data: d,
        dataType: "json",
        success: function(msg) {
            AjaxSucceeded(msg);
        },
        error: AjaxFailed
    });

    function AjaxSucceeded(result) {
        alert(result.d);
        //close modal;
        setTimeout('jQuery.modal.close()', 1000);
        //update grid;

    }
    function AjaxFailed(result) {
        alert(result.status + ' ' + result.statusText);
    }

});

    });

Web Service:

<OperationContract()> _
  <Script.Services.ScriptMethod(responseformat:=Script.Services.ResponseFormat.Json)> _
   <WebInvoke(Method:="POST")> _
     Public Function SeeFile(ByVal filename As String) As String
       Dim path As String = "C:\batchjun302009\batchservice\Uploads\"
       path += filename

       Dim objStreamReader As StreamReader
       objStreamReader = File.OpenText(path)

      Dim someString As String = ""
      Dim counter As Integer = 0
      Dim arr() As Array
      Dim list As New ArrayList
      Dim dte As String
      Dim dep As String = ""
      Dim day As String = ""
      Dim month As String = ""
      Dim year As String = ""



      Dim sb As New StringBuilder
      sb.Append("<table><tr><th>Date</th><th>Deposit</th></tr>")
      sb.Append("<tr>")


    While objStreamReader.Peek() <> -1
        someString = objStreamReader.ReadLine()
        '3 for dat 5 for money
        If someString.Length < 1 Then
            Continue While
        Else


            list.AddRange(someString.Split(","c))
            'will have to convert date to something more user friendly
            dte = list(3)
            year = dte.Substring(0, 4)
            month = dte.Substring(4, 2)
            day = dte.Substring(6, 2)
            sb.Append("<td>")
            dte = month + "/" + day + "/" + year
            sb.Append(dte)
            sb.Append("</td><td>")
            sb.Append(dep)
            sb.Append("</td></tr>")

            dep = list(5)
            list.Clear()
            '... do whatever else you need to do ...
        End If
    End While
    sb.Append("</table>")

    Return sb.ToString

End Function

related questions