为什么我的WebService调用只对一个用户失败?

时间:2010-09-30 10:23:14

标签: c# .net web-services asmx

我有一个简单的WebService方法,它将数据库结果作为DataSet返回。

此方法对公司中的一个用户失败,但适用于其他所有用户 这是崩溃:

    CRASH! GetCustomer - 
ExtractDomesticCommercialState: Exception:InvalidOperationException 
Message:There is an error in XML document (1, 877). 
Source:     System.Xml TargetSite: Deserialize StackTrace:    
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)     
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)     
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)     
at Cwc.Common.basis2_ws.Basis2WebService.GetRetailChargeGroupByInstId(String instId)     
at Cwc.Common.Basis2ServiceLayer.GetRetailChargeGroupByInstId(String instId)     
at Cwc.WaterWorks.Console.frmMain.GetCustomer(String customerKey, Boolean afterCreate)

Exception:FormatException Message:Input string was not in a correct format. 
Source:     mscorlib TargetSite: StringToNumber 
StackTrace:    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)     
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)     
at System.String.System.IConvertible.ToInt32(IFormatProvider provider)     
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)     
at System.Data.XSDSchema.HandleElementColumn(XmlSchemaElement elem, DataTable table, Boolean isBase)     
at System.Data.XSDSchema.HandleParticle(XmlSchemaParticle pt, DataTable table, ArrayList tableChildren, Boolean isBase)     
at System.Data.XSDSchema.HandleComplexType(XmlSchemaComplexType ct, DataTable table, ArrayList tableChildren, Boolean isNillable)     
at System.Data.XSDSchema.InstantiateTable(XmlSchemaElement node, XmlSchemaComplexType typeNode, Boolean isRef)     
at System.Data.XSDSchema.HandleTable(XmlSchemaElement node)     
at System.Data.XSDSchema.HandleDataSet(XmlSchemaElement node, Boolean isNewDataSet)     
at System.Data.XSDSchema.LoadSchema(XmlSchemaSet schemaSet, DataSet ds)     
at System.Data.DataSet.ReadXSDSchema(XmlReader reader, Boolean denyResolving)     
at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)     
at System.Data.DataSet.ReadXmlSerializable(XmlReader reader)     
at System.Data.DataSet.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)     
at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable, Boolean wrappedAny)     
at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable)     
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderBasis2WebService.Read18_Item()     
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer25.Deserialize(XmlSerializationReader reader)     
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 

客户端是.Net WinForms应用程序 我已经验证了Webservice中的方法正确生成XML 似乎反序列化失败了

可能是因为她正在运行.Net Framework 4并且应用程序是为3.5构建的吗?

2 个答案:

答案 0 :(得分:1)

Exception:FormatException Message:Input string was not in a correct format

用户机器上的文化是否与其他工作中的文化相同?只是一个想法,因为它可能使用不同的文化,因此使用不同的IFormatProvider

答案 1 :(得分:0)

查看堆栈跟踪的中间位置......

at Cwc.WaterWorks.Console.frmMain.GetCustomer(String customerKey, Boolean afterCreate)

Exception:FormatException Message:Input string was not in a correct format. 
Source:     mscorlib TargetSite: StringToNumber 
StackTrace:    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)     
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) 

看起来像从String到Int的解析错误....我建议你尝试调查这个区域。