1

以下の jquery コードで次のサービスを呼び出そうとすると 500 エラーが発生します。

result.status = 500 result.statusText = "System.ServiceModel.ServiceActivationException"

SVC サービスは次のとおりです。

    [WebInvoke( Method = "POST", 
                UriTemplate = "/tools/data/SearchAll")]
    public JsonArray SearchAll(string tool, JsonObject filters)
    {...}

jQuery サービス呼び出しは次のとおりです。

    //Generic function to call WCF  Service
    function callService() {
        $.ajax({
            type: type, //GET or POST or PUT or DELETE verb
            url: url, // Location of the service
            data: data, //Data sent to server
            contentType: contentType, // content type sent to server
            dataType: dataType, //Expected data format from server
            processdata: processData, //True or False
            success: function (msg) {//On Successfull service call
                serviceSucceeded(msg);
            },
            error: serviceFailed// When Service call fails
        });
    }



    function searchAll() {
        var tool = "1";
        var filters = '{{ "col": "thiscol", "val": "thisval" }, { "col": "thiscol2", "val": "thisval2" }, { "col": "thiscol3", "val": "thisval3"}}';
        type = "POST";
        url = "ToolService.svc/tools/data/SearchAll";
        contentType = "application/json; charset=utf-8";
        dataType = "json";
        data = '{ "tool": "' + tool + '", "filters" : "' + filters + '" }',
        processData = false;
        method = "SearchAll";
        callService();
    }
4

1 に答える 1

1

これを整理したところ、サービス メソッドに渡された json の形式が正しくないことが判明しました。

助けてくれてありがとう。

于 2012-04-10T21:49:03.250 に答える