且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 POST(json 数据)调用 REST 服务方法时出现错误请求错误?

更新时间:2023-09-08 19:15:46

为了收集有关数据流和错误位置的其他信息,您可能会受益于在服务端启用 WCF 跟踪.以下链接应提供足够的详细信息:http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

In order to gather additional information about the data flow and location of the error you may benefit from enabling WCF Tracing on the service side. The following link should provide sufficient details: http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

关于您的场景中的错误,我怀疑客户端和服务的消息编码设置不一致.我想知道可能是:

Regarding the error in your scenario, I suspect that the message encoding is not set consistently for the client and service. I wonder if maybe the:

BodyStyle = WebMessageBodyStyle.WrappedRequest

应该是:

BodyStyle = WebMessageBodyStyle.Wrapped

BodyStyle = WebMessageBodyStyle.Bare

因此请求和响应具有相同的包装样式.

so the request and response have the same wrapping style.

问候,