开发者

Set Response format inside a function according to Accept header and not outside with ResponseFormat = WebMessageFormat.Json in REST

i am using the Plain old XML template from WCF REST Starter Kit Preview 2 to build a REST service and i would like to 开发者_StackOverflowset the ResponseFormat inside the OperationContract, not outside(not with ResponseFormat = WebMessageFormat.Json) because i want to set it accordingly to the Accept Header in the Request. and ideally i would like to be able to set the RequestFormat from inside the OperationContract also, acording to the Content-Type header.

So, could anyone tell me how i can do it, or point me towards some examples.

chers,

Later Edit: so i don't want to have things like "format" in the UriTemplate, i just want one UriTemplate, no ResponseFormat (and no RequestFormat at some point) and the ResponseBody to be output according to the AcceptHeader

[WebHelp(Comment = "For Service testing purposes")]
[WebGet(UriTemplate = "Echo")]
[OperationContract]
public ResponseBody Echo()


You'll have to strip off most of the WCF REST code and rebuild it yourself. There is no support for content-type negotiation out of the box. I am lead to believe the starter kit has an example using their extensibility points, you may want to check with them.


http://damianblog.com/2008/10/31/wcf-rest-dynamic-response/ is a good place to start

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜