0
我在這裏瘋狂地生氣,也許有人能幫我弄清楚發生了什麼。我有一個WCF服務公開使用webinvoke功能,像這樣:反序列化WCF中的JSON在.NET 4.0中拋出xml錯誤
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "registertokenpost"
)]
void RegisterDeviceTokenForYoumiePost(test token);
用於測試類的datacontract看起來是這樣的:
[DataContract(Namespace="Zooma.Test", Name="test", IsReference=true)]
public class test
{
string waarde;
[DataMember(Name="waarde", Order=0)]
public string Waarde
{
get { return waarde; }
set { waarde = value; }
}
}
當發送下面的JSON消息服務, { 「測試」:{ 「waarde」: 「喇嘛」 }}
跟蹤日誌給我的錯誤(下圖)。我試圖用只是一個字符串,而不是數據類型(void RegisterDeviceTokenForYoumiePost(string token);)但我得到同樣的錯誤。所有的幫助表示讚賞,無法弄清楚。它看起來是從JSON消息中創建無效的XML,但我沒有在這裏做任何自定義序列化。
The formatter threw an exception while trying to deserialize the message: Error in
deserializing body of request message for operation 'RegisterDeviceTokenForYoumiePost'.
Unexpected end of file. **Following elements are not closed**: waarde, test, root.</Message><StackTrace>
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message,
Object[] parameters)