我正在尝试使用以下XML模式创建一个简单的Web服务作为对某些操作的响应。
<?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工具,我为这个XML模式生成了C#类,并在我的webservice应用程序中将该类用作消息。在我尝试使用.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 ---
我发现一篇文章似乎在谈论与我的错误相关的内容,但这对我没有帮助。
请有任何见解。
答案 0 :(得分:0)