System.Xml.Serialization.XmlSerializer.Deserialize

本文关键字:Deserialize XmlSerializer Serialization Xml System | 更新日期: 2023-09-27 17:56:42

Get Error in System.Xml.Serialization.XmlSerializer.反序列化此XML文件接收表单Salesfroce和异常在绑定中发生。查询() 方法。

string xml = @"<?xml version='1.0' encoding='UTF-8'?>
                <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' 
                        xmlns='urn:enterprise.soap.sforce.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
                        xmlns:sf='urn:sobject.enterprise.soap.sforce.com'>
                        <soapenv:Body>
                            <queryResponse>
                                <result>
                                    <done>true</done>
                                    <queryLocator xsi:nil='true'/>
                                    <records xsi:type='sf:Contact_Transaction__c'>
                                        <sf:Id xsi:nil='true'/>
                                        <sf:Is_in_SLA__c>Yes</sf:Is_in_SLA__c>
                                    </records>
                                    <records xsi:type='sf:Contact_Transaction__c'>
                                        <sf:Id xsi:nil='true'/>
                                        <sf:Is_in_SLA__c>Yes</sf:Is_in_SLA__c>
                                    </records>
                                </result>
                            </queryResponse>
                        </soapenv:Body>
                    </soapenv:Envelope>";

上部 XML 文档是 soap responcemessage,它在获取自定义对象数据时从 salesforce 接收。 此 XML 消息是有效的 XML 消息。如果我尝试使用解脱方法手动反序列化对象,则还会出现 XML 内部文档错误

我的完整堆栈跟踪:[格式异常:输入字符串的格式不正确。 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) +9416251 System.Double.Parse(String s, NumberStyles style, IFormatProvider provider) +36 System.Xml.XmlConvert.ToDouble(String s) +99 Microsoft.Xml.Serialization.Generated Assembly.XmlSerializationReaderSforceService.Read16_NullableOfDouble(Boolean checkType) +146 Microsoft.Xml.Serialization.Generated Assembly.XmlSerializationReaderSforceService.Read511_Contact_Transaction__c(Boolean isNullable, Boolean checkType) +9903 Microsoft.Xml.Serialization.Generated Assembly.XmlSerializationReaderSforceService.Read579_sObject(Boolean isNullable, Boolean checkType) +8124 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSforceService.Read14_QueryResult(Boolean isNullable, Boolean checkType) +1855 Microsoft.Xml.Serialization.Generated Assembly.XmlSerializationReaderSforceService.Read722_queryResponse() +594 Microsoft.Xml.Serialization.Generated Assembly.ArrayOfObjectSerializer111.Deserialize(XmlSerializationReader reader) +75 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +130

[无效操作异常:XML 文档 (1, 461) 中存在错误。 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) +630 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) +33 System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +1007 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +221

System.Xml.Serialization.XmlSerializer.Deserialize

看看你的模型对象"queryResponse",它缝隙不能设置双精度类型的字段,因为收到的值格式无效。可能是该值为空(nil='true'),并且该字段不可为空。