Response status code does not indicate success: 415 (Cannot process the message because the content type 'application/xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.).
using (var client = new HttpClient()) { client.BaseAddress = new Uri(webApiUriRoot); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Clear(); //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml")); response = client.PostAsXmlAsync("api/" + functionUri, requestObj).Result; response.EnsureSuccessStatusCode(); var resultContent = response.Content.ReadAsAsync<T>(); return resultContent.Result; }
我是这么调用的。
从提示信息上看,是由于content type不对,WCF期望是text/xml,但是你发送的是application/xml。
我只能提示你下,我没使用过。
意思我懂,但不知道怎么解决