maybe I am doing something wrong, but I am returning XML from my WCF Rest service, which was built since VS 2010. In the fiddle, you can see here that it returns test / html as the content type
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 222
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 16 Aug 2010 20:49:55 GMT
So, I went ahead and added the following to the webget attribute in my method, but it still returns text / html ... I suppose I should return the content type text / xml because I really return XML?
Here is my method, I added ResponseFormat to the attribute ... I was not sure that I needed bodystyle (I have no idea what it does, but saw it in the example :-))
[WebGet(UriTemplate = "", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml)]
public List<SampleItem> GetCollection()
{
return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Hello" } };
}
anyway, after changing and rebuilding the project, it still returns the wrong content type ... am i missign somthing?
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 222
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 16 Aug 2010 20:54:15 GMT
EDIT
, , NO EFFECT, ...
WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
fiddler, - /xml.
, , , .
- , ?