【发布时间】:2013-09-26 14:44:10
【问题描述】:
我的 post 方法有问题..
这是我的界面
public interface Iinterface
{
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "inventory?")]
System.IO.Stream inventory(Stream data);
}
还有功能..
public System.IO.Stream inventory(System.IO.Stream data)
{
//Do something
}
好吧,如果从客户端发送内容类型为 text/plain 或 application/octet-stream 的作品完美,但客户端无法更改内容类型,而他的内容类型是 text/xml,我得到一个错误..
The exception message is 'Incoming message for operation 'inventory' (contract
'Iinterface' with namespace 'http://xxxx.com/provider/2012/10') contains an
unrecognized http body format value 'Xml'. The expected body format value is 'Raw'.
This can be because a WebContentTypeMapper has not been configured on the binding.
有人可以帮助我吗?
谢谢。
【问题讨论】:
-
为什么客户端不能改变它的内容类型?它只是一个 HTTP 请求头。
-
我问自己同样的问题,但他说我无论如何都做不到..
-
您不能期望发送和接收内容类型为
text/xml的原始数据流。我相信在这种情况下,您将不得不在您的服务上编写另一个方法来接受 xml,然后转换为流。 -
@EkoostikMartin,您可以将
text/xml(以及application/json)发送到接收原始数据流的操作。您只需要设置适当的内容类型映射器。
标签: c# wcf post content-type