POST:使用jQuery调用Web服务方法时出现“无效的Web服务调用,缺少参数值”错误 [英] POST: “Invalid web service call, missing value for parameter” error when calling a web service method using jQuery

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

问题描述

大家好我得到了错误,同时使用jquery在HTML页面中调用web-method。



< soap:envelope xmlns:soap =http://www.w3.org/2003/05/soap-envelopexmlns:xsi =http ://www.w3.org/2001/XMLSchema-instancexmlns:xsd =http://www.w3.org/2001/XMLSchema>< soap:body>< soap:fault>< soap:code>< soap:value> soap:Receiver< soap:reason>< soap:text xml:lang =en> System.Web.Services.Protocols.SoapException:服务器无法处理请求。 ---> System.Xml.XmlException:根级别的数据无效。 System 1.Xml.XmlTextReaderImpl.Throw(例外e)



at System.Xml.XmlTextReaderImpl.Throw(String res,String arg)



at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()

<在System.Xml.XmlTextReaderImpl.ParseDocumentContent()上的




at System.Xml.XmlTextReaderImpl.Read()



在System.Xml.XmlTextReader.Read()



在System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read(在System.Web.Services上的System.Xml.XmlReader.MoveToContent()






。 System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()








at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()

>
at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()



at System .Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)



在System.Web.Services.Protocols.SoapServerProtocol.Initialize()



在System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,HttpContext context,HttpRequest request,HttpResponse response,Boolean& abortProcessing)





我这样的剧本

$(文件)。 ready(function(){





$(#btnok)。click(function(){



// var json = Sys.Serialization.JavaScriptSerializer.serialize(obj);

var title = $(#title)。val();

var name = $(#name)。val();

var city = $(#city)。val();

var state = $(#state)。val();

var date = $(#date)。val();

var description = $(#description)。val();

var qualification = $(#qualification)。val();

var Compensation = ;

var openings =;

var phone =;

var email =;

var zipcode =;

var job _categories =;

var client_id =;

var data = {title:$(#title)。val(),name:$( #name)。val(),city:$(#city)。val(),state:$(#state)。val(),date:$(#date)。val() ,赔偿:,开头:,电话:,电子邮件:,邮政编码:,说明:$(#description)。val(),资格:$(#qualification)。 val(),job_categories:,client_id:2};





// var data = {title:$( #title)。val(),name:$(#name)。val(),city:$(#city)。val(),state:$(#state)。val( ),date:$(#date)。val(),duration:$(#duration)。val(),pay:$(#pay)。val(),type:$(#键入 )VAL(),行业:$( #行业 )VAL(),状态:$( #状态 )VAL(),说明:$( #说明)VAL()资格:$(#qualification)。val()};

var data = JSON.stringify(data);

alert(data);

$ .ajax({

类型:POST,

url:http:// localhost:3658 / HostingService.asmx / SETPostJobDetails,

data:JSON.stringify(data),//{''title'':+ title + ,''C.Name'':+ name +,''city'':+ city +,''state'':+ state +,''date'':+ date + ,''持续时间'':+ duratin +,''pay'':+ pay +,''industry'':+ industry +,''type'':+ type +,' 'status'':+ status +,''description'':+ description +,''qualified'':+ qualified +},

// data:/ /{''title'':''+ $(#title)。val()+'',''C.Name'':''+ $(#name)。val ()+'',''city'':''+ $(#city)。val()+'',''state'':''+ $(#state) .val()+'',''date'':''+ $(#date)。val()+'',''duration'':''+ $(#duration ).val()+'',''pay'':''+ $(#pay)。val()+'', 'industry'':''+ $(#industry)。val()+'',''type'':''+ $(#type)。val()+'' ,''status'':''+ $(#status)。val()+'',''description'':''+ $(#description)。val()+ '',''qualified'':''+ $(#qualification)。val()+''},

contentType:application / json; charset = utf- 8,

processData:false,

dataType:json,

成功:函数(数据){

alert(''Success'');

},

错误:函数(数据,状态,错误){

alert( data.responseText);



}

});

});

});

请帮帮我

解决方案

(document).ready(function(){





(#btnok)。 click(function(){



// var json = Sys.Serialization.JavaScriptSerializer.serialize(obj);

var title =


(#title)。val();

var name =


Hi all i got the error, while calling web-method in HTML page using jquery.

<soap:envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:body><soap:fault><soap:code><soap:value>soap:Receiver<soap:reason><soap:text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

at System.Xml.XmlTextReaderImpl.Throw(Exception e)

at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)

at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()

at System.Xml.XmlTextReaderImpl.ParseDocumentContent()

at System.Xml.XmlTextReaderImpl.Read()

at System.Xml.XmlTextReader.Read()

at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()

at System.Xml.XmlReader.MoveToContent()

at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent()

at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()

at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()

at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)

at System.Web.Services.Protocols.SoapServerProtocol.Initialize()

at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)


my script like this
$(document).ready(function () {


$("#btnok").click(function () {

// var json = Sys.Serialization.JavaScriptSerializer.serialize(obj);
var title = $("#title").val();
var name = $("#name").val();
var city = $("#city").val();
var state = $("#state").val();
var date = $("#date").val();
var description = $("#description").val();
var qualification = $("#qualification").val();
var Compensation ="";
var openings = "";
var phone = "";
var email = "";
var zipcode = "";
var job_categories ="";
var client_id = "";
var data = { title: $("#title").val(), name: $("#name").val(), city: $("#city").val(), state: $("#state").val(), date: $("#date").val(), Compensation:"", openings:"", phone:"", email:"", zipcode:"", description: $("#description").val(), qualification: $("#qualification").val(), job_categories:"", client_id:"2" };


// var data = { title:$("#title").val(),name: $("#name").val(), city: $("#city").val(), state: $("#state").val(), date: $("#date").val(),duration:$("#duration").val(),pay:$("#pay").val(),type: $("#type").val(),industry:$("#industry").val(),status:$("#status").val(),description:$("#description").val(),qualification: $("#qualification").val() };
var data = JSON.stringify(data);
alert(data);
$.ajax({
type: "POST",
url: "http://localhost:3658/HostingService.asmx/SETPostJobDetails",
data:JSON.stringify(data),//"{''title'':" + title + ",''C.Name'':" + name + ",''city'':" + city + ",''state'':" + state + ",''date'':" + date + ",''duration'':" + duratin + ",''pay'':" + pay + ",''industry'':" + industry + ",''type'':" + type + ",''status'':" + status + ",''description'':" + description + ",''qualification'':" + qualification + "}",
// data: // "{''title'':''" + $("#title").val() + "'',''C.Name'':''" + $("#name").val() + "'',''city'':''" + $("#city").val() + "'',''state'':''" + $("#state").val() + "'',''date'':''" + $("#date").val() + "'',''duration'':''" + $("#duration").val() + "'',''pay'':''" + $("#pay").val() + "'',''industry'':''" + $("#industry").val() + "'',''type'':''" + $("#type").val() + "'',''status'':''" + $("#status").val() + "'',''description'':''" + $("#description").val() + "'',''qualification'':''" + $("#qualification").val() + "''}",
contentType: "application/json;charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
alert(''Success'');
},
error: function (data, status, error) {
alert(data.responseText);

}
});
});
});
please help me

解决方案

(document).ready(function () {



("#btnok").click(function () {

// var json = Sys.Serialization.JavaScriptSerializer.serialize(obj);
var title =


("#title").val();
var name =


这篇关于POST:使用jQuery调用Web服务方法时出现“无效的Web服务调用,缺少参数值”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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