【问题标题】:Kendo grid and asmx web serviceKendo 网格和 asmx Web 服务
【发布时间】:2013-12-30 20:15:02
【问题描述】:

我希望得到一些帮助 - 我正在尝试从 Kendo 网格向我的 .asmx Web 服务发送请求。我有一个没有参数的版本,但我无法将参数传递给我的 Web 服务,或者至少不知道如何检索它们。 (注意:已编辑以反映解决方案)

// Here's how the transport part of the Kendo Grid looks:

        transport: {
            read: {
                url: function (e) {
                     return "Documents.svc/Read?guid=" + guid + "&Name=" + name + "&Origin=" + origin + "&Groups=" + groups;                                             
                },
                contentType: "application/json; charset=utf-8",                     
                type: "POST" 
            },
            parameterMap: function (data, operation) {
                return JSON.stringify(data);
            }
        }



// And here's the web service:
[ServiceContract(Namespace = "")]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)] 
[AspNetCompatibilityRequirements(RequirementsMode =     AspNetCompatibilityRequirementsMode.Allowed)]
public class Documents 
{

[OperationContract]
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public List<clsDocuments> Read(string guid, string name, string origin, string groups)
{
    var Guid = HttpContext.Current.Request.QueryString["guid"];
    var Name = HttpContext.Current.Request.QueryString["name"];
    var Origin = HttpContext.Current.Request.QueryString["origin"];
    var Groups = HttpContext.Current.Request.QueryString["groups"];

    List<clsDocuments> docList = Utility.GetUnreadDocuments();

    foreach (var doc in docList)
    {
        doc.Modified = DateTime.Parse(doc.Modified).ToShortDateString();
    }
   return docList;
}

}

【问题讨论】:

  • 编辑到文档解决方案。

标签: c# web-services grid kendo-ui asmx


【解决方案1】:

你的数据应该是查询字符串格式:

data: "guid=" + guid + "&name=" + name + "&origin=" + origin .....

【讨论】:

  • 我试过了,但是在我的网络方法中检索它的语法是什么?
  • 对于 Web 服务,应填充参数,这些是非复杂类型。对于 SOAP,参数的顺序应该正确。你有错误吗?
  • 没有错误,但是当我将查询字符串放在 url 函数中并去掉读取中的 data 参数时,一切正常。在 Web 服务端,我只是使用了 HttpContext.Current.Request.QueryString["guid"]。原始问题已使用工作版本进行了更新。非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-27
  • 2012-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多