2
我有一个方法后一个问题..WCF POST请求的内容类型text/xml的
这里是我的接口
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请求头。 – EkoostikMartin
我问自己同样的问题,但他说我不能做任何理由。 – bombai
你不能期望发送和接收内容类型为“text/xml”的原始数据流。我相信在这种情况下,您将不得不在服务上编写另一种方法来接受xml,然后转换为流。 – EkoostikMartin