无效的Web服务调用,缺少参数值:\ u0027sentQuery \ u0027&无效的JSON原语(Invalid web service call, missing value for parameter: \u0027sentQuery\u0027 & Invalid JSON primitive)
不知道为什么我得到这个,但我得到这个错误:
Invalid web service call, missing value for parameter: \u0027sentQuery\u0027
尝试执行jQuery AJAX到我的ASPX Web服务时。
我的AJAX是这样的:
$.ajax({
type: 'GET',
contentType: "application/json; charset=utf-8",
dataType: 'json',
url: "http://localhost:7665/Service1.asmx/theQ",
data: "{\"sentQuery\":" + "\"SELECT OPRID FROM vwPS_BC_JOB_PERS_DAT\"" + "}",
success: function (data) {
console.log(data);
},
error: function (a) {
alert('ERROR: ' + a.responseText);
}
});
我的VB Web服务代码:
_
_
Public Sub theQ(ByVal sentQuery As String)
Dim results As Object = fetchSQLQ("query", sentQuery)
Try
Dim ser As New System.Web.Script.Serialization.JavaScriptSerializer()
Dim strResponse As String = ser.Serialize(results)
Context.Response.Clear()
Context.Response.ContentType = "application/json"
Context.Response.AddHeader("content-length", strResponse.Length.ToString())
Context.Response.Write(strResponse)
HttpContext.Current.ApplicationInstance.CompleteRequest()
Catch ex As Exception
Context.Response.Clear()
Context.Response.ContentType = "application/json"
Context.Response.AddHeader("content-length", ex.Message.Length.ToString())
Context.Response.Write(String.Format("[ERROR: {0}]", ex.Me