当我在ServiceStack中启用AutoQuery功能时,出现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; }
}
有没有办法纠正这个错误?
答案 0 :(得分:1)
现在应该是fixed with this commit,它将位于now available on MyGet的ServiceStack的 v4.0.24 + 版本中。