addItemAttachment

The addItemAttachment service attaches a file to an existing item in the ExtraView database.

Input

Class

Name

Type

Required

Details

AddItemAttachmentRequest

userId

String

Yes

The caller's user ID

AddItemAttachmentRequest

password

String

Yes

The caller's password

AddItemAttachmentRequest

attachment

Object

 

The data handler object as defined by the soap product your using

AddItemAttachmentRequest

itemId

int

?

The int item id. This field is optional if itemIdStr is given, else it is required. It is recommended that you use itemIdStr

AddItemAttachmentRequest

itemIdStr

String

?

The String item Id. This field is optional if itemId is used. It is recommended that you use itemIdStr

AddItemAttachmentRequest

attachmentName

String

No

 

AddItemAttachmentRequest

attachmentDesc

String

No

List of filters for the history

AddItemAttachmentRequest

charset

String

No

 

AddItemAttachmentRequest

contentType

String

No

 

AddItemAttachmentRequest

fieldName

String

No

 

AddItemAttachmentRequest

attachmentDesc

String

No

 

AddItemAttachmentRequest

rowNumber

String

No

 

Output

Class

Name

Type

Required

Details

AddItemAttachmentResponse

success

boolean

Yes

True is succeeded False if failed

AddItemAttachmentResponse

returnCode

String

No

See Appendix for details

AddItemAttachmentResponse

returnMessage

String

No

Human readable message

Example

public static void testAddItemAttachment(EVItemServiceStub stub) {
    try {
        // generate a temp file
        File tempFile = File.createTempFile("ws_test",".txt");
        FileOutputStream fop = new FileOutputStream(tempFile);
        fop.write("!!TEST FILE!!nWS Java Tester built this file!".getBytes());
        fop.flush();
        fop.close();

        // next setup the data source
        DataInputStream dis = new DataInputStream(new FileInputStream(tempFile));
        BufferedReader br = new BufferedReader(new InputStreamReader(dis));

        List bFileList = new ArrayList();

        try {
            byte b;
            while( (b=dis.readByte()) != -1){
                bFileList.add(b);
            }
        } catch (Exception e) {}

        // and now we can send the file
        AddItemAttachmentDocument reqEnvelope =
AddItemAttachmentDocument.Factory.newInstance();
        AddItemAttachmentRequest request =
reqEnvelope.addNewAddItemAttachment().addNewRequest();

        request.setUserId(ServiceClientHelper.ADMIN_USER_ID);
        request.setPassword(ServiceClientHelper.ADMIN_PASSWORD);
        request.setItemId(CREATED_Item_ID);
        byte[] results = new byte[bFileList.size()];
        for (int i=0;i
            results[i] = bFileList.get(i);
        }
        request.setAttachment(results);
        request.setAttachmentName(tempFile.getName());
        request.setCharset("US-ASCII");
        request.setContentType("text/plain");
        request.setAttachmentDesc("this is a test file!");

        AddItemAttachmentResponseDocument resEnvelope =
stub.addItemAttachment(reqEnvelope);
        AddItemAttachmentResponse response =
resEnvelope.getAddItemAttachmentResponse().getReturn();

        if (response.getSuccess()) {
            System.out.println("success: [" +
                    response.getReturnCode() + "] : " +
                    response.getReturnMessage());
            System.out.println("Attachment created for issue " + request.getItemId());
        } else {
            System.out.println("failure: [" +
                    response.getReturnCode() + "] : " +
                    response.getReturnMessage());
        }
         tempFile.delete();
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("nnn");
    }
}