没有调用来自Angularjs的带有datacontract参数的WCF Rest服务?

时间:2015-07-13 07:37:10

标签: angularjs angularjs-service wcf-rest

Angular JS:
  这是来自UI客户端的angularJS服务调用

var obj = {
                        "ReportingId": Rejection.ReportingId,
                        "ErrorCode": Rejection.ErrorCode,
                        "OriginatorCode": Rejection.OriginatorCode,
                        "PrimaryAssetClass": Rejection.PrimaryAssetClass,
                        "MsgType": Rejection.MsgType,
                        "FeedbackType": Rejection.FeedbackType,
                        "ReportType": 1,
                        "RegionCode": Rejection.RegionCode,
                        "ErrorStatus": Rejection.ErrorStatus,
                        "Assignee": Rejection.Assignee,
                        "Case": Rejection.Case,
                        "Status": Rejection.Status,
                        "Comment": Rejection.Comment,
                        "UserName": Rejection.UserName,
                        "RejectId": Rejection.RejectId,
                        "Profile": Rejection.Profile
                    };
                    alert("before save call " + Rejection.IssueId);
                    $http({
                        method: "post",
                        url: "http://localhost:55467/WCFServiceHost/DFAService.svc/SaveDtccCommentHistory",
                        datatype: "json",
                        data: obj,
                        headers: { "content-type": "application/json; charset=utf-8;" }
                    }).sucess(function (data) {
                        alert("On succeess of save " + Rejection.IssueId);
                    })
                    .error(function (msg, code) {
                        alert("On failure of save " + Rejection.IssueId);

                    });

WCF服务合同:

    [OperationContract]
    [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json,
      ResponseFormat = WebMessageFormat.Json,
        BodyStyle=WebMessageBodyStyle.Wrapped,
      UriTemplate = "SaveDtccCommentHistory")]
    string SaveDtccCommentHistory(DcSaveDtccCommandData dccriteria);

服务实施如下:

public string SaveDtccCommentHistory(DcSaveDtccCommandData dccriteria)
    {
        return "hello".ToString();
    }   

我尝试从浏览器调试.Fiddler说“方法不允许。请帮我解决这个问题

0 个答案:

没有答案