【问题标题】:Using ServiceStack AutoQuery feature causes Autogeneration of WSDL failed error使用 ServiceStack AutoQuery 功能导致自动生成 WSDL 失败错误
【发布时间】:2014-07-26 14:06:31
【问题描述】:

当我在 ServiceStack 中启用自动查询功能时,我收到 Autogeneration of WSDL failed 错误。

显示以下异常:

System.Runtime.Serialization.InvalidDataContractException: 
Type 'ServiceStack.QueryResponse`1[T]' cannot be exported as a schema type because it is an open generic type. 
You can only export a generic type if all its generic parameter types are actual types.
   at System.Runtime.Serialization.DataContractSet.EnsureTypeNotGeneric(Type type)
   at System.Runtime.Serialization.XsdDataContractExporter.Export(ICollection`1 types)
   at ServiceStack.XsdUtils.GetXmlSchemaSet(ICollection`1 operationTypes)
   at ServiceStack.Metadata.XsdGenerator.ToString()
   at ServiceStack.Metadata.WsdlMetadataHandlerBase.GetWsdlTemplate(XsdMetadata operations, String baseUri, Boolean optimizeForFlash, String rawUrl, String serviceName)
   at ServiceStack.Metadata.WsdlMetadataHandlerBase.Execute(IRequest httpReq, IResponse httpRes)

AutoQuery 返回的QueryResponse 类型似乎是泛型类型。

请求对象:

[Route("/Data/ApplicationLog")]
public class AutoQueryApplicationLog : QueryBase<ApplicationLog>
{
    public long[] Id { get; set; }
    public string[] LogLevel { get; set; }
    public string[] Source { get; set; }
    public string[] Message { get; set; }
    public string[] Host { get; set; }
    public string[] Type { get; set; }
    public string[] Logger { get; set; }
    public string[] CreatedBy { get; set; }
    public DateTime? CreatedDateGreaterThanOrEqualTo { get; set; }
}

响应对象:

[DataContract(Name = "ApplicationLog", Namespace = "http://Rx30.Services.aa.is/types")]
public class ApplicationLog
{
    [PrimaryKey]
    [AutoIncrement]
    [DataMember]
    public long Id { get; set; }

    [DataMember]
    public string LogLevel { get; set; }

    [DataMember]
    public string Source { get; set; }

    [DataMember]
    public string Message { get; set; }

    [DataMember]
    public string StackTrace { get; set; }

    [DataMember]
    public string Host { get; set; }

    [DataMember]
    public string Type { get; set; }

    [DataMember]
    public string Logger { get; set; }

    [DataMember]
    public DateTime CreatedDate { get; set; }

    [DataMember]
    public string CreatedBy { get; set; }
}

有没有办法纠正这个错误?

【问题讨论】:

  • 您是否还可以添加使用 AutoQuery 导致此错误的请求/响应 DTO?
  • 我已经添加了请求和响应 DTO 的

标签: servicestack


【解决方案1】:

现在应该是 fixed with this commit,它将在 ServiceStack 的 v4.0.24+ 版本中,即 now available on MyGet

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多