【问题标题】:Webservices Error related to XML Schema与 XML Schema 相关的 Web 服务错误
【发布时间】:2010-10-21 10:32:39
【问题描述】:

我正在尝试使用以下 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# 类,并将该类用作我的 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 --- 

我发现一篇文章似乎在谈论与我的错误相关的内容,但这对我没有帮助。

请提供任何见解。

【问题讨论】:

标签: .net web-services xml-serialization


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-11-13
  • 2011-05-05
  • 1970-01-01
  • 2011-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多