我尝试过各种组合来使用jQuery发送POST请求到RESTful WCF。希望有人能够模拟并让它正常工作。代码在这里:http://pastebin.com/Ua97919C
我已经使用WCF工作了2年,但每次发送POST请求都让我很苦恼。
我已经努力让它正常工作了4天,看了至少35-40篇文章。
最终,这个请求将从iPhone发送到WCF。
当我用Fiddler检查时,错误大多是:“服务器遇到处理请求过程中的错误。异常消息是'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.'。请参阅服务器日志以获取更多详细信息。异常堆栈跟踪为:
System.ServiceModel.Dispatcher.DemultiplexingDispatchMessageFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
1
,全局文件只需添加到WCFPost.Service
项目中,在这里是我使用的带有服务的 ajax 调用 http://pastebin.com/2veXcN8Z - Rafay