Web Services Attachment-Related Methods

This article contains the following topics:
casm173
This article contains the following topics:
This section describes the Web Services attachment-related methods. Only file attachments are handled by these methods; link type attachments are handled by generic methods, such as CreateObject(). In addition, file uploads through Web Services employ the Direct Internet Message Encapsulation (DIME) protocol. Your SOAP implementation must support DIME in order to use these methods.
createAttachment
The following parameters apply to the createAttachment method:
Parameter
Data Type
Description
SID
INTEGER
Identifies the session retrieved from logging in.
repositoryHandle
STRING
Identifies the object handle of a document repository.
objectHandle
STRING
Identifies the object handle of a call request, change order, or issue, to which this attachment is attached.
This parameter can be NULL, however, you must manage the attachment ID that is returned because the attachment is not associated to a ticket when NULL is passed in.
description
STRING
Identifies the description for the attachment object.
fileName
STRING
Identifies the full path of the file to be uploaded.
Description
Uploads a file to the back-end server. An uploaded file is stored in a document repository specified by the repositoryHandle. An attachment object is then created and attached to a ticket object specified by the objectHandle. The attachment object has all the information for accessing the newly uploaded file in the repository.
Returns
createAttachment has the following returns:
Parameter
Type
Description
<Handle>
STRING
Identifies the object handle of the newly created attachment object.
Could not perform the operation, policy limit exceeded
  • Symptom:
When using the createAttachment() web service method to attach a document to an existing request or incident, you receive this error, even when the web services policy setting for attachments is set to -1(unlimited), which is the out-of-the-box default setting. You may receive this error when calling the web service method when there are no attached files in the received SOAP message. You must attach at least one file to the SOAP message before calling the createAttachment() web service method.
  • Solution:
Set your SOAP implementation to support Direct Internet Message Encapsulation (DIME), and attach the file to be uploaded manually using DIME support before calling the createAttachment() method.
You can refer to the examples on how to support DIME from the $NX_ROOT\samples\sdk\websvc\java\test3_attachments directory.
Example: Visual Basic .NET
This code example illustrates sample Visual Basic .NET code to attach a file using DIME support before calling the createAttachment() web service method.
Dim reqContext As SoapContext = objCA SDM_WS.RequestSoapContext Dim dimeAttach As New DimeAttachment("image/gif", TypeFormat.MediaType, "c:\test.txt") reqContext.Attachments.Add(dimeAttach) strResult = objCA SDM_WS.createAttachment(sid, "doc_rep:1002", "cr:400001", "my desc", "c:\test.txt")
For information about the DIME attachment methods used in the previous sample code, see the Microsoft website. For programs written in other languages, see your documentation for the SOAP implementation that supports DIME.
Example: Java
This code example illustrates sample Java code to attach a file using DIME support before calling the createAttachment() web service method.
FileDataSource fds = new FileDataSource(filename); DataHandler dhandler = new DataHandler(fds); CA SDM._setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME); CA SDM.addAttachment(dhandler); String handle = CA SDM.createAttachment(sid, repHandle, objHandle, description, filename);
removeAttachment
The following parameters apply to the removeAttachment method:
Parameter
Type
Description
SID
Integer
Identifies the SID of the current login session.
attHandle
String
Identifies the object handle of an attachment to be removed.
Description
Removes an attachment from a ticket object. The attached file is then removed from the repository.
Returns
Nothing.
attachURLLinkToTicket
The following parameters apply to the attachURLLinkToTicket method:
Parameter
Type
Description
SID
Integer
Identifies the session retrieved from logging in.
docId
Integer
Identifies the unique ID of the ticket.
URL
String
Indicates the URL to attach to the ticket.
attmntName
String
Identifies the name of the attachment.
Description
String
Indicates the description of the attachment.
Description
Attaches a URL link to a ticket.
Example:
CA SDM.attachURLLinkToTicket(sid, "cr:400001", "http://<URL NAME>", "<URL NAME>", "Broadcom Technologies Website");