0

在System.Xml.Serialization.XmlSerializer.Deserialize中获取错误,此 XML 文件接收表单 Salesfroce 并且在 binding.Query() 方法中发生异常。

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 文档是在获取自定义对象数据时从 salesforce 接收的肥皂响应消息。此 XML 消息是有效的 XML 消息。如果我尝试使用反序列化方法手动反序列化对象,那么还会出现 XML 内部文档错误

我的完整堆栈跟踪:: [FormatException: 输入字符串的格式不正确。] 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.GeneratedAssembly.XmlSerializationReaderSforceService.Read16_NullableOfDouble(Boolean checkType) +146 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSforceService.Read511_Contact_Transaction__c(Boolean is903 Microsoft, Boolean is903 Microsoft) .Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSforceService.Read579_sObject(Boolean isNullable, Boolean checkType) +8124 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSforceService.Read14_QueryResult(Boolean isNullable,Boolean checkType) +1855 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSforceService.Read722_queryResponse() +594 Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer111.Deserialize(XmlSerializationReader reader) +75 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader字符串 encodingStyle、XmlDeserializationEvents 事件)+130

[InvalidOperationException: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[]参数)+221

4

1 回答 1

0

看看您的模型对象“queryResponse”,它接缝无法设置 Double 类型的字段,因为收到的值没有有效的格式。可能是该值为空(nil='true')并且该字段不可为空。

于 2013-01-30T11:14:34.473 回答