How to retrieve Files using Webservice getFileAttachments
http://server:7001/CoreService/services/Attachment
Here i am able to get the File content using the getFileAttachment webservice but how to convert this to File using SOAP UI or Java Code?
The service returns bytes under the tag ‘content’. SOAP UI will only provide the bytes. For Java just write those bytes to a file
The following is a sample in C# (not including writing bytes to file system) but essentially will be the same in Java
AttachmentService.GetFileAttachmentResponseType response = client.getFileAttachment(request);
if (response.statusCode == AttachmentService.ResponseStatusCode.SUCCESS)
{
AttachmentService.AgileGetFileAttachmentResponse[] responses = response.responses;
foreach (AttachmentService.AgileGetFileAttachmentResponse resp in responses)
{
AttachmentService.AgileFileAttachmentResponseType[] attachments = resp.attachment;
if (attachments != null)
{
foreach (AttachmentService.AgileFileAttachmentResponseType attachment in attachments)
{
if (fileName.Equals(attachment.name))
{
isExists = true;
if (currentAttachmentRowId == null || currentAttachmentRowId < attachment.rowId)
{
currentAttachmentRowId = attachment.rowId;
byte[] bytes = attachment.content;
}
}
}
}
}
}