400(错误请求)错误:从骨干模型的获取基础设施调用 WCF .net 服务

发布于 2025-01-03 14:45:37 字数 2185 浏览 1 评论 0原文

我正在尝试建立我的第一个实现 RESTful WCF 服务的骨干模型。到目前为止,这是我所拥有的:我的路由器创建了用户模型,我只想执行 fetch()。我创建了一个虚拟 Web 服务,只是为了在纠正实际的 WS 代码之前尝试让它运行。

编辑:我相信这是我的 web.config 的问题,不确定我需要什么

我的路由器:

define([
    'backbone', 
    'dashboard',
    'models/UserModel'
], 
function(Backbone, Dashboard, UserModel) {
    var homeRouter = Backbone.Router.extend({
        initialize : function() {
            Backbone.history.start();           
        },

        routes : {
            '' : 'home',
            'docs': 'docs'

        },

        'home' : function() {

            var user = new UserModel({userId: 'cjestes'});
            user.fetch();

        },

        'docs' : function() {
            //load docs page

        }

    });

    return new homeRouter();
});

我的型号:

define([
    'jquery',
    'backbone'
], 
function($, Backbone) {
    //Docs Metro View
    var userModel = Backbone.Model.extend({
        userId: " ",

        url:  "services/User.svc/GetUserInformation",

        initialize: function () {

            this.userId = this.get("id");

        }

    });

    // Return the Docs Model
    return userModel;
});

我的 SVC:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.Web.Hosting;
using System.Collections.Specialized;


namespace Mri.Dashboard.services
{

    public class User : IUser
    {
        public string GetUserInformation()
        {
            return "hello";

        }
    }
}

我的接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Web;

namespace Mri.Dashboard.services
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IUser" in both code and config file together.
    [ServiceContract]
    public interface IUser
    {
        [OperationContract]
        string GetUserInformation();
    }
}

I'm trying to set up my first Backbone Model that implements RESTful WCF services. Here is what I have so far: My router creates the User Model and I simply want to perform a fetch(). I created a dummy webservice just to try and get it going before I right my actual WS code.

EDIT: I believe this is a problem with my web.config, not sure what I need

MY ROUTER:

define([
    'backbone', 
    'dashboard',
    'models/UserModel'
], 
function(Backbone, Dashboard, UserModel) {
    var homeRouter = Backbone.Router.extend({
        initialize : function() {
            Backbone.history.start();           
        },

        routes : {
            '' : 'home',
            'docs': 'docs'

        },

        'home' : function() {

            var user = new UserModel({userId: 'cjestes'});
            user.fetch();

        },

        'docs' : function() {
            //load docs page

        }

    });

    return new homeRouter();
});

My MODEL:

define([
    'jquery',
    'backbone'
], 
function($, Backbone) {
    //Docs Metro View
    var userModel = Backbone.Model.extend({
        userId: " ",

        url:  "services/User.svc/GetUserInformation",

        initialize: function () {

            this.userId = this.get("id");

        }

    });

    // Return the Docs Model
    return userModel;
});

MY SVC:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.Web.Hosting;
using System.Collections.Specialized;


namespace Mri.Dashboard.services
{

    public class User : IUser
    {
        public string GetUserInformation()
        {
            return "hello";

        }
    }
}

MY INTERFACE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Web;

namespace Mri.Dashboard.services
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IUser" in both code and config file together.
    [ServiceContract]
    public interface IUser
    {
        [OperationContract]
        string GetUserInformation();
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

噩梦成真你也成魔 2025-01-10 14:45:37

对于任何偶然发现这一点的人,我最终使用了 .svc/config - less WCF 实现。我从这个模板开始,它列出了启动并运行 REST WCF 所需的一切。

http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd -9d7b-e54c845394cd

我能够将此模板与骨干模型的内置同步结合使用,非常易于操作和使用。

For anyone who stumbles upon this I ended up using a .svc/config - less WCF implmentation. I started with this template which lays out everything you need to do it get REST WCF up and running.

http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd

I was able to use this template in conjunction with the backbone model's built in sync, it is very easy to do and use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文