我在我的 WCF 服务中使用以下数据协定,当我的客户端是 C# 控制台应用程序时它可以工作
[DataContract]
public class PersonField
{
private string _fieldName;
private object _fieldValue;
public PersonField()
{
}
public PersonField(string FieldName, object FieldValue)
{
_fieldName = FieldName;
_fieldValue = FieldValue;
}
[DataMember]
public string FieldName
{
get { return _fieldName; }
set { _fieldName = value; }
}
[DataMember]
public object FieldValue
{
get { return _fieldValue; }
set { _fieldValue = value; }
}
}
但
当我从 SOAP UI(http://www.soapui.org/) 尝试它时,我得到以下响应
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
<faultstring xml:lang="en-US">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter entities. The InnerException message was 'Element FieldValue from namespace http://schemas.datacontract.org/2004/07/Entities.Person cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.'. Please see InnerException for more details.</faultstring>
</s:Fault>
</s:Body>
</s:Envelope>
我不能在 WCF 中使用类型对象吗?