无效的Web服务调用,缺少值参数 [英] Invalid web service call, missing value for parameter

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

问题描述

我一直在寻找这一段时间并不能看到问题的所在。任何帮助是极大的AP preciated。

I have been looking at this for a while and can't see where the problem is. Any help is greatly appreciated.

[WebMethod(true)]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static string neighbourhoodTeam(string force, string neighbourhood) 
{
    //StreamManager streamMan = new StreamManager();
    //return streamMan.StreamManagerUrlHandler("http://policeapi2.rkh.co.uk/api/" + force + "%2F" + neighbourhood + "%2F" + "people");
    return neighbourhood + force;
}

jQuery的:

jQuery:

function getOfficers(force, neighbourhood) {
    $.ajax({
        type: "GET",
        contentType: "application/json; charset=utf-8",
        url: "../police/crimerequest.aspx/neighbourhoodTeam",
        data: JSON.stringify({ "force": force, "neighbourhood": neighbourhood }),
        dataType: "json",
        success: function (data) {
            var results = $.parseJSON(data.d);
            $.each(results, function (i) {
                businessCards.push(generateOfficerBusinessCard(
                            results[i].name,
                            results[i].rank,
                            results[i].contact_details.mobile,
                            results[i].contact_details.tel,
                            results[i].contact_details.email))
            });
            PoliceApp.businessCardsPlaceHolder.html(businessCards.toString());
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
            alert(xhr.responseText);
            return false;
        }
    });
}

和我得到: {消息:无效的Web服务调用,缺少值参数:\ u0027force \ u0027,堆栈跟踪:

推荐答案

试着用发过程数据:假在阿贾克斯PARAMS。 jQuery将默认情况下再次字符串化。

Try sending with processData: false in your ajax params. jQuery will stringify again by default.

使用小提琴手或类似工具来检查网络流量,看看是越来越实际发送到Web服务。

Use fiddler or similar tool to inspect network traffic and see what is getting actually sent to your web service.

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

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