我有一個WCF Web Api Restful web服務。WCF Web API如何向每個端點添加參數
我希望每一個服務調用都採用可選參數:suppress_status_codes。有沒有辦法做到這一點wihtout添加參數和處理每一個終點,如:
[WebGet(UriTemplate = "{somearg1}/{somearg2}/?supress={suppressStatusCodes}")
public HttpResponseMessage<string> SomeEndPoint(string somearg1, long somearg2, bool suppressStatusCodes)
{
// handle suppress status codes
// do rest of call
suppress_status_code的目的是爲Flash集成。如果一個web服務返回200閃存以外的任何東西都不可能處理郵件正文,所以如果supress_status_codes爲true,我需要能夠在HttpResponseMessage中返回一個帶有錯誤和錯誤狀態代碼的「200」。
由於這個原因,Twitter的API具有相同的可選參數。
用簡要描述更新了OP。 – 2011-06-10 18:34:13
謝謝,這讓我走上了正確的軌道,並且我已經將這種模式用於我需要的其他一些東西。我在這裏有這個OP的後續問題:http://stackoverflow.com/questions/6313461/c-wcf-webapi-modify-responses-httpcontent – 2011-06-11 01:15:03