---
title: "DCMTK: DcmSCP, error:QueryRetrieveLevel larger remaining bytes"
author: "qimo601"
date: "2012-11-06T09:48:56Z"
tags: []
categories: ["编程语言"]
slug: "dcmtk-dcmscp-error-queryretrievelevel-larger-remaining-bytes"
draft: false
lastmod: "2012-11-06T09:50:13Z"
id: 1717259
url: "https://qimo601.iteye.com/blog/1717259"
---

最近在DcmSCU发送一个findRequest后，DcmSCP总是报一个错误：

 

hi, all.

when i send a findRequest in DcmSCU, it will be successful to receive response.  
but then the DcmServer will take place an error, as follows.

**Quote:**

"2012-11-03 16:12:25.758 INFO: Sending C-Find Response"   
"2012-11-03 16:12:27.795 DEBUG: C-FIND Response successfully sent"   
"2012-11-03 16:12:29.678 DEBUG: DcmDataset::read() TransferSyntax="Little Endian Implicit""   
"2012-11-03 16:12:29.678 WARN: DcmItem: Length of element (0008,0052) is odd"   
"2012-11-03 16:12:29.679 ERROR: DcmElement: QueryRetrieveLevel (0008,0052) larger (414531) than remaining bytes (20) in file, premature end of stream"   
"2012-11-03 16:12:29.679 DEBUG: DIMSE Error, detail (if available): 0006:020d DIMSE: receiveCommand: cmdSet-&gt;read() Failed2012-11-03 16:12:29.679 DEBUG: 0001:0004 Invalid stream"   
"2012-11-03 16:12:59.681 DEBUG: DcmSCP: Association Terminated"   
"2012-11-03 16:12:59.681 DEBUG: +++++++++++++++++++++++++++++

 

最后的解决方法是：

 

I have found the anwser [Something about the findscu tool](http://forum.dcmtk.org/viewtopic.php?f=1&t=2206&hilit=findProvider)

we should implement the callback function to set response-&gt;DimseStatus=STATUS\_Success;

**Code:**

typedef void (\*DIMSE\_FindProviderCallback)(  
        /* in \*/  
        void \*callbackData,  
        OFBool cancelled, T\_DIMSE\_C\_FindRQ \*request,  
        DcmDataset \*requestIdentifiers, int responseCount,  
        /* out \*/  
        T\_DIMSE\_C\_FindRSP \*response,  
        DcmDataset \*\*responseIdentifiers,  
        DcmDataset \*\*statusDetail);

DCMTK\_DCMNET\_EXPORT OFCondition  
DIMSE\_findProvider(  
        /* in \*/  
        T\_ASC\_Association \*assoc,  
        T\_ASC\_PresentationContextID presIdCmd,  
        T\_DIMSE\_C\_FindRQ \*request,  
        DIMSE\_FindProviderCallback callback, void \*callbackData,  
        /* blocking info for data set \*/  
        T\_DIMSE\_BlockingMode blockMode, int timeout);

my callBack function:

**Code:**

void FindProviderCallback(  
   /* in \*/   
   void \*callbackData,    
   OFBool cancelled, T\_DIMSE\_C\_FindRQ \*request,   
   DcmDataset \*requestIdentifiers, int responseCount,  
   /* out \*/  
   T\_DIMSE\_C\_FindRSP \*response,  
   DcmDataset \*\*responseIdentifiers,  
   DcmDataset \*\*statusDetail)  
{  
   if (responseCount&gt;1)  
   {  
      //\*responseIdentifiers=NULL;  
      response-&gt;DimseStatus=STATUS\_Success;  
   }  
   else     
   {  
      if(request-&gt;DataSetType==DIMSE\_DATASET\_PRESENT) //or some other conditions are met  
         \*responseIdentifiers=new DcmDataset(\*requestIdentifiers);       
   }  
}

Thanks all.