Using SOAP createAttachment to attach a file to Configuration Item (CI) returns "AHD03332:UploadFile failed" for file names that are too long. "CUploadLocalFile() - Failed to move file" is written in the stdlog.

Document ID : KB000006574
Last Modified Date : 14/02/2018
Show Technical Document Details
Issue:

When createAttachment is used to attach a file to a Configuration Item, the operation may fail due to a limitation on the size of the file name.

Here is an example which includes a fileName that is too long:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.ca.com/UnicenterServicePlus/ServiceDesk">
<soapenv:Header/>
<soapenv:Body>
<ser:createAttachment>
<sid>1000257423</sid>
<repositoryHandle>doc_rep:1002</repositoryHandle>
<objectHandle>nr:4089E66FA5206F49B0CEC2415B0AC0F3</objectHandle>
<description>test01long</description>
<fileName>C:\temp\1234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt</fileName>
</ser:createAttachment>
</soapenv:Body>
</soapenv:Envelope> 
 
 

When the "fileName" length is at least 1 character less, the attachment succeeds.  For example, using the following fileName in the above xml would succeed (assuming that the file actually exists with the specified name and in the specified path):

<fileName>C:\temp\123456789012345678901234567890123456789012345678901234567890123456789012345678901234.txt</fileName>

 

Below is an example of the reply that is returned upon failure:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>AHD03332:UploadFile failed</faultstring>
<faultactor/>
<detail>
<ErrorMessage>AHD03332:UploadFile failed</ErrorMessage>
<ErrorCode>1</ErrorCode>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

 

Below is an example of the associated message that are written in the stdlog:

 

04/27 22:28:39.36 ITSMW12SD      rep_daemon           4864 SIGNIFICANT  AttmntMng.c           1922 GetLastSubFolder() - New directory C:/PROGRA~2/CA/SERVIC~1/site/attachments/default/servicedesk/files/rep_folder_00001 was created.
04/27 22:28:39.37 ITSMW12SD      rep_daemon           4864 SIGNIFICANT  FileMng.c             1267 CopyFile() - Failed to duplicate the file C:/PROGRA~2/CA/SERVIC~1/bopcfg/www/CATALINA_BASE/temp/1094048665_4089E66FA5206F49B0CEC2415B0AC0F3_1234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt. (No such file or directory (2))
04/27 22:28:39.37 ITSMW12SD      rep_daemon           4864 SIGNIFICANT  FileMng.c             1311 MoveFile() - Failed to copy the file C:\PROGRA~2\CA\SERVIC~1\bopcfg\www\CATALINA_BASE\temp\1094048665_4089E66FA5206F49B0CEC2415B0AC0F3_1234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt. (No such file or directory (2))
04/27 22:28:39.37 ITSMW12SD      rep_daemon           4864 ERROR        AttmntMng.c           1050 CUploadLocalFile() - Failed to move file 'C:\PROGRA~2\CA\SERVIC~1\bopcfg\www\CATALINA_BASE\temp\1094048665_4089E66FA5206F49B0CEC2415B0AC0F3_1234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt' to 'C:/PROGRA~2/CA/SERVIC~1/site/attachments/default/servicedesk/files/rep_folder_00001/754F822EE153F645A6D95570E6933163_400351_1094048665_4089E66FA5206F49B0CEC2415B0AC0F3_1234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt.gz'.
04/27 22:28:39.59 ITSMW12SD      sda                   188 ERROR        sda.cpp               2411 AHD11001:Failed to upload the file 'rep_folder_00001/754F822EE153F645A6D95570E6933163_400351_1094048665_4089E66FA5206F49B0CEC2415B0AC0F3_1234567890123456789012345678901234567890123456789012345678901234567890123456789012345.txt.gz'.

 

Environment:
CA Service Desk Manager 14.1.03 on Windows, with the solution to problem USRD 3700.Note: The solution to problem USRD 3700 enables createAttachment to work with Configuration Items.
Cause:

In Windows, the default total path length must not exceed 260 characters. The maximum length consists of a drive letter, followed by a colon (":"), followed by a backslash ("\"), followed by 256 characters, and ending with a null terminator character.

When CA Service Desk Manager attaches a file to any object, like a Call_Req object or nr object, it must first make the file identifier unique.  To do that, it adds both the session_id and the object_id to the file name and then saves the file in the CA SDM repository.

The maximum length of the file name could be different, depending on the object type.  In the case of a Configuration Item, the OBJECT-HANDLE-ID is 32 characters long; for a Call_Req object, the object handle ID is 6 characters long.  The difference is 26 chars. Thus, the filename for CI's only supports a file name length of 84 characters,  whereas the file name for Call_Req's supports a maximum file name length of 110 characters.

Resolution:

When using createAttachment with a Configuration Item, be sure that the filename is 84 characters or less.

Additional Information:

TEC599833 stdlog contains "rep_daemon ERROR AttmntMng.c CUploadLocalFile()" for an attachment file that has a very long Windows path with filename