Intuit.Ipp.Exception.SerializationException:生成XML文档时出错. —> System.InvalidOperationException:生成XML文档时出错. —> System.InvalidOperationException:ItemElementName的值与System.Decimal的类型不匹配;你需要将它设置为Intuit.Ipp.Data.ItemChoiceType.@ UnitPrice.
在Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write163_ItemBasedExpenseLineDetail(String n,String ns,ItemBasedExpenseLineDetail o,Boolean isNullable,Boolean needType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write181_Line(String n,String ns,Line o,Boolean isNullable,Boolean needType)
在Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write185_Bill(String n,String ns,Bill o,Boolean isNullable,Boolean needType)
在Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterBill.Write186_Bill(Object o)
—内部异常堆栈跟踪结束—
在System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,Object o,XmlSerializerNamespaces namespaces,String encodingStyle,String id)
在System.Xml.Serialization.XmlSerializer.Serialize(Stream stream,Object o,XmlSerializerNamespaces名称空间)
at Intuit.Ipp.Utility.XmlObjectSerializer.Serialize(Object entity)
—内部异常堆栈跟踪结束—
at Intuit.Ipp.Utility.XmlObjectSerializer.Serialize(Object entity)
at Intuit.Ipp.Core.Rest.RestHandler.PrepareRequest(RequestParameters requestParameters,Object requestBody,String oauthRequestUri)
在Intuit.Ipp.DataService.DataService.Update [T](T实体)
Bill的所有ItemBasedExpenseLineDetail成员的值似乎正好是Intuit.Ipp.Data.ItemChoiceType.UnitPrice,如Watch或Immediate Window所示,例如:
?DirectCast(qboItem.Line(0).AnyIntuitObject,Intuit.Ipp.Data.ItemBasedExpenseLineDetail).ItemElementName
UnitPrice {2}
任何想法如何执行更新没有此错误或在哪里进一步查看?
Aaaaaand,就在我发布这个问题时,我在Intuit.Developer社区找到了答案I guess you have the default setting from SDK where request format is XMl and response is Json.
This causes serialization issues which you have mentioned above.
Please add the following lines in your code to have either both request/response in xml or boht in json format.
context.IppConfiguration.Message.Request.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
context.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;