Я пытаюсь создать простой веб-сервис со следующей XML-схемой в ответ на какую-либо операцию.
<?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>
Приведенная выше схема была создана с использованием инструмента XSD.exe VS 2005 с использованием следующего 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 и использовал этот класс в качестве сообщения в своем приложении веб-сервиса.Здесь все нормально, пока я не попытаюсь сделать простой вызов от клиента, созданного с использованием .net framework.
Я получил ошибку:
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 ---
Я нашел одну статью, которая, кажется, что-то говоритсвязано с моей ошибкой, но это не помогает мне.
Любое понимание, пожалуйста.