使用IRequiresRequestStream时出现意外的SerializationException

时间:2017-08-31 07:58:36

标签: deserialization servicestack

我们有一个请求Dto,定义如下:

public class AddDocumentByUploadBinaryRequest: AddDocumentRequest, IRequiresRequestStream
{
    public string FileName { get; set; }

    public Stream RequestStream { get; set; }
}

AddDocumentRequest类的定义是:

public class AddDocumentRequest: IReturn<ResponseBase>
{
    public Guid Id { get; set; }

    public string[] Tags { get; set; }

    public Guid? LotId { get; set; }

    public Guid? ContactId { get; set; }

    // never need it to attach document to existing bill
    //public Guid? BillId { get; set; }

    public Guid? FolioId { get; set; }

    public Guid? JobTaskId { get; set; }

    public Guid? TaskId { get; set; }

    public Guid? TenantInvoiceId { get; set; }

    public Guid? InspectionTaskId { get; set; }

    public Guid? InspectionReportAreaId { get; set; }

    public Guid? InMessageId { get; set; }

    public DocumentTypes? DocumentType { get; set; }

    public EventLinkTypes? DocumentArea {   get; set; }

    public Guid? MessageId { get; set; }

    public Guid? LinkId { 
        get {
            switch (DocumentArea) {
                //case EventLinkTypes.Bill:
                //  return BillId;
                case EventLinkTypes.Contact:
                    return ContactId;
                case EventLinkTypes.Inspection:
                    return InspectionTaskId;
                case EventLinkTypes.InspectionReport:
                    return InspectionTaskId;
                case EventLinkTypes.InspectionReportArea:
                    return InspectionReportAreaId;
                case EventLinkTypes.Job:
                    return JobTaskId;
                case EventLinkTypes.Lot:
                    return LotId;
                case EventLinkTypes.Task:
                    return TaskId;
                case EventLinkTypes.Message:
                    return MessageId;
                default:
                    return FolioId;
            }
        }
    }
}

API大部分时间都有效,但偶尔会出现“无法绑定到请求”错误,其中包含以下详细信息:

  

无法绑定到请求'AddDocumentByUploadBinaryRequest';错误代码:SerializationException;字段名称: iD ;消息:' Z~ l _$ Ǒ 6j Ǒ Xƾ ԯ㵂 ; W; / k 6 ;ׯG $ O ` V Ĵ AZ [S幉&GT;&GT; [ANO   XN $&LT; pHGN [C | 5#

? '是' iD '的无效值

捕获的错误消息表明二进制正文意外反序列化并失败。

客户端设备始终使用Content-Type:application / octet-stream标头。我已经阅读了ServiceStack的相关源代码,但我想不出为什么二进制体仍然会进入反序列化。

任何想法都会被贬低。

0 个答案:

没有答案