【发布时间】:2014-09-23 08:29:01
【问题描述】:
花费大量时间最终让我的 WCF 服务以Content-Type: application/x-www-form-urlencoded; 的身份接受请求(使用此处建议的 Stream Best way to support "application/x-www-form-urlencoded" post data with WCF?)
终于成功了。
但是我得到的响应是
Content-Type: application/xml; charset=utf-8
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">result</string>
但我想要的是
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
result
可以在哪里设置/破解?
目前方法如下:
[WebInvoke(UriTemplate = "generate_license", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST")]
[OperationContract]
string GenerateLicense(Stream period);
【问题讨论】:
-
我认为响应类型为 application/x-www-form-urlencoded 没有意义,您是否向客户发布了表单?您想通过将响应设置为内容类型来实现什么目标?
-
好吧,也许这没有意义。我正在做的是接受来自过时网络服务的一些简单调用并生成许可证文本并将其发送给他们,他们也将其作为原始文本除外..不是 XML
-
如果你想发送纯文本,那么
text/plain更有意义。