【发布时间】:2011-02-19 11:45:46
【问题描述】:
我快疯了,也许有人可以帮我弄清楚发生了什么。我有一个使用 webinvoke 公开函数的 WCF 服务,如下所示:
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "registertokenpost"
)]
void RegisterDeviceTokenForYoumiePost(test token);
测试类的数据契约如下所示:
[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 消息时, { “测试”: { “沃德”:“布拉” } }
跟踪日志给了我错误(如下)。我只用一个字符串而不是数据类型(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)
【问题讨论】:
标签: wcf json serialization xml-serialization .net-4.0