无效的Web服务调用,具有骨干和WebService webMethods的参数值缺失 [英] Invalid web service call, missing value for parameter with Backbone and Webservice webmethods

查看:571
本文介绍了无效的Web服务调用,具有骨干和WebService webMethods的参数值缺失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能为骨干,以与asp.net web服务的SOAP接口的方法保存和检索数据?因为我从这个的WebMethod错误,但实际上 POST 包含的参数。

Is it possible for backbone to interface with asp.net soap webservice methods for saving and retrieving the data? because i got this error from the webmethod but actually the POST contains the parameters.

[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static Dummy SaveDummy(Dummy myDummy)
        {
            Dummy dumdum = myDummy;
            HttpContext.Current.Session["data"] = dumdum;
            return myDummy;
        }

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
        public static Dummy FetchDummy()
        {
            return (Dummy)HttpContext.Current.Session["data"];
        }

        public class Dummy
        {
            private string _name;
            private string _script;

            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }

            public string Script
            {
                get
                {
                    return _script;
                }
                set { _script = value; }
            }
        }

骨干示范

  window["model"] = Backbone.Model.extend({
        initialize: function () {
            console.log("CREATED");
        },
        defaults:{
            name:"Please enter your name",
            script:"Hello World"
        },
        urlRoot: "index.aspx/SaveDummy",
        validate: function (attrs) {

        }
    });

应用程序

$("document").ready(function () {

    var myModel = new model({
        name: "Stack Overflow",
        script: "alert('Hi SO')"
    });

    var myView = new view({
        model: myModel,
        el: $("#placeholder")
    });

    console.log("SAVING");
    myModel.save();

    console.log("FETCHING");
    myModel.fetch();

POST

{名:堆栈溢出,脚本:警报('嗨SO')}

无效的Web服务调用,参数缺失值:'myDummy

我也期待与类似的问题,这是由做一些像解决其他职位
{myDummy = {名:堆栈溢出,脚本:警报('嗨SO')}} 。这怎么可能通过骨干生成?

I did look into other posts with similar problem, which were solved by doing something like {myDummy={"name":"Stack Overflow","script":"alert('Hi SO')"}} . How could this be generated using Backbone?

推荐答案

所有骨干通过Backbone.Sync处理的服务器端同步这是专为两件事情:

All of the server-side synchronization in Backbone is handled through Backbone.Sync which is designed for two things:


  • 与JSON(而不是SOAP / XML)工作的REST API的

  • 扩展

所以,你需要重写Backbone.Sync行为跟你的后端。这似乎是相对直接的。一些指南可以在这些链接中找到:

So you will need to override the Backbone.Sync behavior to talk to your backend. It appears to be relatively straight-forward. Some guidance can be found in these links:

  • SO post about overriding Backbone.Sync
  • Blog post about consuming XML services in Backbone

这篇关于无效的Web服务调用,具有骨干和WebService webMethods的参数值缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆