c# – 对WCF的Ajax调用返回“传入消息具有意外的消息格式’Raw’.操作的预期消息格式..“
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – 对WCF的Ajax调用返回“传入消息具有意外的消息格式’Raw’.操作的预期消息格式..“,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2062字,纯文字阅读大概需要3分钟。
内容图文
![c# – 对WCF的Ajax调用返回“传入消息具有意外的消息格式’Raw’.操作的预期消息格式..“](/upload/InfoBanner/zyjiaocheng/804/e9594cfbaa1b4d4c9636070aab89c6d7.jpg)
使用.NET framework 3.5.
我无法想象发生了什么?使用相同的方法,我的Get WCF服务似乎很好.
不确定,缺少什么?
WCF:
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public void PutInventory(int caseId, DateTime dateReceived, string tamisCaseNo, string oarNo, string tin, string taxPdr, int oarTypeCd, string idrsOrgAssigned, string idrsTeAssigned, DateTime dateRequestComp, int tasCriteriaCd, string tasExpidateCd, DateTime dateEntered, string remarks)
{
InventoryDAL.PutInventory(caseId, dateReceived, tamisCaseNo, oarNo, tin, taxPdr, oarTypeCd, idrsOrgAssigned, idrsTeAssigned, dateRequestComp, tasCriteriaCd, tasExpidateCd, dateEntered, remarks);
}
Ajax调用我的webform:
$.ajax({
url: "Services/IVOOARInventoryService.svc/PutInventory",
type: 'POST',
cache: false,
dataType: 'json',
data: ({
caseId: '<%=Request.QueryString["id"]%>', dateReceived: $("#dateEntered").val(), tamisCaseNo: $("#tamisCaseNo").val(), oarNo: $("#OARNo").val(), tin:$("#tin").val(), taxPdr: $("#taxPeriod").val(), oarTypeCd: $("#oarType").val(), idrsOrgAssigned: $("#idrsOrgAssigned").val(), idrsTeAssigned: $("#idrsTeAssigned").val(), dateRequestComp: $("#dateRequestComp").val(), tasCriteriaCd: $("#tasCriteriaComp").val(), tasExpidateCd:$("#tasExpediateCd").val(), dateEntered: $("#dateEntered").val(), remarks: $("#remarks").val()
}),
error: function (jqXHR, textStatus, errorThrown) {
$("div#spinner").fadeOut("slow");
alert(errorThrown);
},
success: function (json) {
$("div#spinner").fadeOut("slow");
}
});
我的错误:
{"ExceptionDetail":{"HelpLink":null,"InnerException":null,"Message":"The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.
解决方法:
刚想通了,需要使用“JSON.stringify”
例:
data: JSON.stringify({
caseId: "18"
...etc..
}),
http://encosia.com/asmx-scriptservice-mistake-invalid-json-primitive/
内容总结
以上是互联网集市为您收集整理的c# – 对WCF的Ajax调用返回“传入消息具有意外的消息格式’Raw’.操作的预期消息格式..“全部内容,希望文章能够帮你解决c# – 对WCF的Ajax调用返回“传入消息具有意外的消息格式’Raw’.操作的预期消息格式..“所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。