I'm relatively new to WCF, specifically the WCF 4 REST Online开发者_StackOverflow Template.
I am testing a basic method:
[WebGet(UriTemplate = "Test")]
public string Test()
{
return "Test";
}
The response generated is:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Hello World</string>
Is there any way to send back anything other than XML or JSON, or is there any way to modify the response?
You could return Stream
; WCF won't apply formatting and you would be free to write whatever content you wanted to the Stream.
This article may help.
Edit:
Also, keep in mind that if you are going to use this method to serve up a file, for example, then you'll need to find some way to set the MIME type appropriately. This thread should give you some ideas. Personally, I prefer the Registry Read method suggested by @Serguei.
精彩评论