Description:
This document describes where to find a sample Java Application that uses DIME and how to change it to use MIME to illustrate how to upload attachments over Web Services methods: createAttachment() and createAttmnt() .
Solution:
There is a sample set of java code that illustrates how to make calls to createAttachment() and createAttmnt() under the Service Desk Installation directory:
NX_ROOT\samples\sdk\websvc\java\test3_attachments\
Please refer to NX_ROOT\samples\sdk\websvc\TableOfContents.doc and NX_ROOT\samples\sdk\websvc\java\run_java_test_bat.txt for the documentation.
The code under NX_ROOT\samples\sdk\websvc\java\test3_attachments uses DIME which has limitations with file size being greater than 1 MB.
One solution would be to use MIME, which is supported by CA Service Desk Manager.
To use MIME, change the following code:
CHANGE:
// Setup the client soap request FileDataSource fds = new FileDataSource(filename); DataHandler dhandler = new DataHandler(fds); ((org.apache.axis.client.Stub)usd)._setProperty( Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME ); ((org.apache.axis.client.Stub)usd).addAttachment(dhandler); // createAttachment() String attmntHandle = usd.createAttachment(sid, ServiceDeskDocumentRepository, newRequestHandle.value, "createAttachment test file", filename );
TO:
// Setup the client soap request FileDataSource fds = new FileDataSource(filename); DataHandler dhandler = new DataHandler(fds); ((org.apache.axis.client.Stub)usd)._setProperty( Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_MIME ); ((org.apache.axis.client.Stub)usd).addAttachment(dhandler); // createAttachment() String attmntHandle = usd.createAttachment(sid, ServiceDeskDocumentRepository, newRequestHandle.value, "createAttachment test file", filename );