【发布时间】:2015-12-23 20:49:11
【问题描述】:
我正在调用在我的控制台测试应用程序中添加为 WebReference 的 SalesForce API。
它需要的参数之一是对象类型。准确地说,以下是我的代码:
SFObject sfObject = new SFObject
{
type = "User",
Item = new { ExternalId = 2}
};
我正在传递上面的代码,其中 API 期望 Item 的类型为 object()。
当我进行最后一次调用时,我看到以下错误:
{"f__AnonymousType0`1[System.Int32] 无法序列化
下面是我的“添加网络参考”下载的SFObject的定义。
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.81.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:sfobject.sfapi.successfactors.com")]
public partial class SFObject {
private object itemField;
private string typeField;
private System.Xml.XmlElement[] anyField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("businessKeys", typeof(BusinessKeys))]
[System.Xml.Serialization.XmlElementAttribute("id", typeof(string))]
public object Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}
/// <remarks/>
public string type {
get {
return this.typeField;
}
set {
this.typeField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlAnyElementAttribute()]
public System.Xml.XmlElement[] Any {
get {
return this.anyField;
}
set {
this.anyField = value;
}
}
}
我四处搜索,似乎 WCF 序列化存在一些问题,但我在这里没有使用 WCf。有什么办法可以解决这个问题吗?
【问题讨论】:
-
请提及 SFObject 类和这个属性以及所有与它相关的东西。
-
@vahidkargar:刚刚添加了信息
-
这个错误有什么不清楚的地方?匿名类型不能序列化。
标签: c# wcf salesforce anonymous-types