0
我正在嘗試使用以下XML模式作爲對某些操作的響應的簡單Web服務。與XML Schema相關的Webservices錯誤
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="TResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="STATUS" type="xs:string" minOccurs="0" />
<xs:element name="DESCRIPTION" type="xs:string" minOccurs="0" />
<xs:element name="Result" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="List" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Attributes" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="AttrName" type="xs:string" minOccurs="0" />
<xs:element name="AttrValue" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
上述模式是使用VS 2005的XSD.exe工具使用以下XML創建的。
<?xml version="1.0" encoding="utf-8"?>
<TResponse>
<STATUS>string</STATUS>
<DESCRIPTION>string</DESCRIPTION>
<Result>
<List>
<Attributes>
<AttrName>Test1</AttrName>
<AttrValue>TestV1</AttrValue>
</Attributes>
</List>
</Result>
</TResponse>
現在用xsd.exe工具的幫助下,我已經生成的C#類此XML架構和使用該類作爲消息在我的web應用程序。在我嘗試使用.net框架創建客戶端的簡單調用之前,一切都很好。
我收到的錯誤是
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'TResponseResultListAttributes[][]' to 'TResponseResultListAttributes[]'
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Evidence evidence)
at System.Web.Services.Protocols.SoapServerType..ctor(Type type, WebServiceProtocols protocolsSupported)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
--- End of inner exception stack trace ---
我發現一篇文章,這似乎是在說有關我的錯誤的東西,但沒有被我的幫助。
任何洞察請。
到文章的鏈接是http://www.kerrywong.com/2006/11/04/xml-serialization-surprise-in-vs-2005/ – Aakash 2010-10-21 10:34:47
究竟是什麼錯誤消息告訴您。您可能創建了錯誤的模式類,使用推理創建模式並不奇怪。手動滾動會更好。 – leppie 2010-10-21 10:43:11
感謝leppie,但我試圖做到沒有成功。 – Aakash 2010-10-21 13:40:39