javascript 肥皂调用 ASP.NET Web 服务时出错
我有一个正在运行的 ASP.Net 测试 Web 服务,但我不断收到 500 个错误,如下所示:
"System.InvalidOperationException: Request format is invalid: text/xml.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
"
当我使用 javascript 调用它时。
它是一个简单的 Web 服务,它将单个参数作为字符串并将其返回给客户端。请帮忙!
I have a working ASP.Net test web service, but I keep getting 500 errors as:
"System.InvalidOperationException: Request format is invalid: text/xml.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
"
when I call it with javascript.
It is a simple web service that takes a single parameter as a string and returns it to the client. Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于那些可能有帮助的人来说,问题在于正确设置标头中的 SOAPAction:
$.ajax({
类型:“帖子”,
网址:目标,
内容类型:“文本/xml”,
数据:soapBody,
数据类型:“xml”,
处理数据:假,
beforeSend: 函数( xhr ){
xhr.setRequestHeader(
“肥皂行动”,
“http://blahblah.com/Services/MethodName”
);
},
....
For those of you who this might help, the issue was setting the SOAPAction in teh header correctly:
$.ajax({
type: "post",
url: target,
contentType: "text/xml",
data: soapBody,
dataType: "xml",
processData: false,
beforeSend: function( xhr ){
xhr.setRequestHeader(
"SOAPAction",
"http://blahblah.com/Services/MethodName"
);
},
....
确保您的
mess
变量不包含 GET 样式的查询字符串,例如'?a=1&b=2'
。您需要以 POST 格式(例如 JSON)发送。尝试将contentType
更改为contentType: "application/json; charset=utf-8"
Make sure that your
mess
variable doesn't contain GET-style query string like'?a=1&b=2'
. You need to send it in POST format, for example in JSON. Try to changecontentType
tocontentType: "application/json; charset=utf-8"