jqwidgets网格中的Web服务错误绑定

时间:2014-02-05 07:14:50

标签: c# jquery asp.net web-services

我想从here运行一个示例项目。它是使用ASP.net Web服务的jqxGrid示例。但问题是在运行样本后没有任何值,存在解析问题。

    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public object GetData()
    {
        string result;
        WebResponse response;
        WebRequest request = HttpWebRequest.Create("http://www.jqwidgets.com/jquery-widgets-demo/demos/sampledata/data.php");
        response = request.GetResponse();
        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
        {
            result = reader.ReadToEnd();
            reader.Close();
        }
        return new JavaScriptSerializer().DeserializeObject(result);            
    }

这是webservice.asax中的.cs代码

网络服务错误:

    System.InvalidOperationException: There was an error generating the XML document. ---> System.NotSupportedException: The type System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] is not supported because it implements IDictionary.
       at System.Xml.Serialization.TypeScope.GetDefaultIndexer(Type type, String memberInfo)
       at System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference)
       at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
       at System.Xml.Serialization.XmlSerializationWriter.CreateUnknownTypeException(Type type)
       at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType)
       at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType)
       at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write2_anyType(Object o)
       at Microsoft.Xml.Serialization.GeneratedAssembly.ObjectSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
       at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
       --- End of inner exception stack trace ---
       at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
       at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces)
       at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue)
       at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream)
       at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues)
       at System.Web.Services.Protocols.WebServiceHandler.Invoke()

我需要知道错误究竟意味着什么?有没有解决?

1 个答案:

答案 0 :(得分:0)

您确定运行了正确的示例 - ASP.NET \ jqxGrid \ WebService - Binding? 您还需要在Site.Master中更新jQuery对1.10.2的引用。