2012-02-24 47 views
0

我試圖做到以下幾點:WCF REST複雜的輸出參數

[OperationContract] 
[WebGet(ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] 
int Create(string key, out IEnumerable<SomeClass> items); 

它「作品」,但行爲是每一個「SomeClass的」序列化爲XML,JSON不是。 我希望將它們格式化爲JSON以及其他所有內容。有任何想法嗎?

回答

1

您是否嘗試過添加RequestFormat?

[WebGet(ResponseFormat = WebMessageFormat.Json, RequestFormat=WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] 
+0

我有,無濟於事。我會仔細檢查一下。 – Malachi 2012-02-24 08:07:48

+0

雙重檢查。仍然回來XML – Malachi 2012-02-24 08:42:40

1

發生這種情況可能是因爲您可能已經忽略了Service標記中的Factory屬性。 嘗試添加此:

Factory="System.ServiceModel.Activation.WebServiceHostFactory"