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