-
Notifications
You must be signed in to change notification settings - Fork 8
Home
UI view of the Custom Sampler:
The sampler appears in sampler list as 'Custom SOAP Sampler'. It can work with one or more attachments (multiple attachments) and also without attachments, this way behaving as normal Soap sampler.
As seen in the screenshot it has the following features:
- drop-down for SOAP protocol version with values 1_1 and 1_2
- URL - endpoint for the request
- checkbox 'Treat selected attachment as response'. If this is enabled then for services that in response return attachments the assertions can be made. So if the option is enabled there is a choice to locate the proper attachment in response by content type or content ID
- fields for adding attachment: browser to locate the file, checkbox 'Use relative paths', Content ID, type (values: resource, value). If resource is added then the content of the file is loaded as stream to the attachment object. If value is selected then the value from text is taken 'as is'.
- content-type. Values: auto, text/plain, text/xml, text/html, application/xml, application/gzip. If other types are required then the project needs to be updated and rebuilt.
- buttons to Add and Remove attachments
Other than that the sampler behaves just as other ordinary sampler.
Programmatic use of the plugin in JSR223 PreProcessor, for example to add, delete attachments from the code because there is exposed a getter: 'getAttachmentDefinition()':
//add attachments
ArrayList attList = new ArrayList();
def att1 = ctx.getCurrentSampler().getAttachmentDefinition();
att1.attachment = new File(pathToFile);
att1.contentID ="someContentID";
att1.contentType="application/xml"; //one of selections from the dropdown
att1.type=1; //1 means resource, 2 means variable
attList.add(att1);
//confirm (set) adding all attachments
ctx.getCurrentSampler().setAttachments(attList);
The built jar is in the directory - target. Please note this was originally compiled with java 1.8, so at the past it was necessary to make sure JMeter was using Java 8 as well. According to information on Internet: "First and foremost, JMeter 2.12 is now fully compliant with Java 8." Since version 1.3 of the plugin Java 1.7 is used at compilation so it would be functional if JMeter is using Java 7 or 8.