首页 新闻 会员 周边 捐助

[WCF]Error:There is an error in XML document

0
[已解决问题] 解决于 2011-10-20 16:34

在WCF调用中出错: There is an error in XML document

问题补充:
System.InvalidOperationException: There is an error in XML document (21, -331). ---> System.Xml.XmlException: '', hexadecimal value 0x0B, is an invalid character. Line 21, position -331.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, StringBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType)
at System.Xml.XmlTextReaderImpl.ParseCharRefInline(Int32 startPos, Int32& charCount, EntityType& entityType)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.ParseText()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderJobService.Read4_JobOfferDTO(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderJobService.Read10_GetOfferByPageResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer11.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
System.Xml.XmlException: '', hexadecimal value 0x0B, is an invalid character. Line 21, position -331.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res, String[] args)
at System.Xml.XmlTextReaderImpl.ParseNumericCharRefInline(Int32 startPos, Boolean expand, StringBuilder internalSubsetBuilder, Int32& charCount, EntityType& entityType)
at System.Xml.XmlTextReaderImpl.ParseCharRefInline(Int32 startPos, Int32& charCount, EntityType& entityType)
at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
at System.Xml.XmlTextReaderImpl.ParseText()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderJobService.Read4_JobOfferDTO(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderJobService.Read10_GetOfferByPageResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer11.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
today4king的主页 today4king | 老鸟四级 | 园豆:3499
提问于:2011-10-19 18:13
< >
分享
最佳答案
0

在WCF服务端的web.config中增加如下的配置:

  <system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Warning" propagateActivity="true">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="路径/日志文件名.svclog"/>
</sharedListeners>
</system.diagnostics>

然后看一下日志中的错误信息。

dudu | 高人七级 |园豆:30736 | 2011-10-19 18:17

路径可以是相对路径么?

today4king | 园豆:3499 (老鸟四级) | 2011-10-19 18:30

@今朝-TODAY: 绝对路径

dudu | 园豆:30736 (高人七级) | 2011-10-19 18:48

@dudu: 其它错误信息是有的,唯独这次的没有。对了,这个配置是写在服务端,原来错写在客户端的。

today4king | 园豆:3499 (老鸟四级) | 2011-10-19 21:01

@今朝-TODAY: 在web.config中将basicHttpBinding > binding > readerQuotas的maxStringContentLength设置为327680,服务器与客户端都进行这样的设置。

dudu | 园豆:30736 (高人七级) | 2011-10-20 13:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册