Web服务404总是由于复杂的类型

时间:2015-07-07 10:12:00

标签: javascript json linq wcf linq-to-sharepoint

我在调用中传递一些复杂数据时遇到问题,一种是HTML,另一种是stringify Json。

REQ_Description = HTML
REQ_Services = JSON.stringify(SomeData) 

这是我的代码

SERVER



 Interface

         [WebGet(UriTemplate = "InsertPedidos/{requestId}/{categorie}/{projectType}/{sla}/{possibleDate}/{desireDate}/" +
                                         "{desireJustification}/{services}/{description}/{workflowState}/{tempId}", 
                                         BodyStyle = WebMessageBodyStyle.Bare,
                    ResponseFormat = WebMessageFormat.Json)]
                int InsertPedidos(string requestId,
                    string categorie, string projectType, string sla, string possibleDate, string desireDate,
                    string desireJustification, string services, string description, string workflowState,
                    string tempId);

实施

 public int InsertPedidos(string pid, string requestId,
            string categorie, string projectType, string sla, string possibleDate, string desireDate,
            string desireJustification, string services, string description, string workflowState, 
            string tempId)
        {
            var data = new LinqToRequestsContext(Elevate.RequestsUrl);
            var ped = data.GetList<FDM_MAINREQUESTSMAINREQUESTS>("FDM_MAINREQUESTS");

            ped.ScopeToFolder(_folder, false);

            var insert = new FDM_MAINREQUESTSMAINREQUESTS()
            {
                REQ_RequestID = double.Parse(requestId),
                REQ_Categorie = double.Parse(categorie),
                REQ_ProjectType = double.Parse(projectType),
                REQ_SlaOnDate = int.Parse(sla),
                REQ_RequestDate = DateTime.Now,
                REQ_PossibleDate = DateTime.Parse(possibleDate),
                REQ_DesireDate = DateTime.Parse(desireDate),
                REQ_DesireJustification = desireJustification,
                REQ_Services = services,
                REQ_Description = description,
                REQ_Worflow_State = int.Parse(workflowState),
                REQ_Origin = 0,
                Title = tempId,
                REQ_CRU_DateCreated = DateTime.Now,
                REQ_CRU_UserCreated = SPContext.Current.Web.CurrentUser.Email
            };
            ped.InsertOnSubmit(insert);
            data.SubmitChanges();
            return 1;
        }

客户端

function InsertOrUpdatePedido(id, how) {
    $("#img_Progress").show();

    var $treemain = $("#tt"); // the source tree
    var data = $treemain.tree("getData", $treemain.tree("getRoot").target);
    var jdata = JSON.stringify(data);

    if (how > 0) {
        this.litem = list.getItemById(how);
    } else {
        var formData = {
            requestId: id,
            categorie: $("#sel_categories option:selected").val(),
            projectType: $("#sel_projecttype option:selected").val(),
            sla: $("#tipoSla").val(),
            possibleDate: $("#dataPrevista").val(),
            desireDate: $("#dataDesejada").val(),
            desireJustification: $("#justificacaoPedido").val(),
            services: jdata,
            description: $("#weditor").Editor("getText"),
            workflowState: "1",
            tempId: tempid
        };


        JSON.stringify(formData);

        jQuery.ajax({
            cache: false,
            type: "GET",
            url: "/_vti_bin/APP/Requests.svc/InsertPedidos",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            data: formData,
            success: function(ret) {
                if (ret === 1) {
                    MessPopups("s", "Pedido efetuado corretamente");
                }
            }
        });
    }
}

有人能给我一些线索吗?我试图解码复杂字段的URI(),因为传递“%2%2 ....”,也试图stingify DATA,没有运气。还有其他方法吗?我想我把代码编写成复杂而不是“KISS”。

我被困了

谢谢 若昂

0 个答案:

没有答案