spinning10 / JMeterSoapSampler

JMeter Soap Sampler with support to attachments
10 stars 8 forks source link

Adding attachments with pre-processor yields "invalid attachment' #4

Closed Sil68 closed 7 years ago

Sil68 commented 7 years ago

I'm trying to create a groovy-based pre-processor (JSR223PreProcessor) for *Custom SOAP Sampler plugin, which is intended to cover to following tasks:

After some quite extensive research on the net--I'm completely new to whole groovy, java, jmeter topic--, I managed to assemble the groovy script shown below.

    // read data from csv input file
    ArrayList recLst = new ArrayList();
    String fldsep = vars.get("fldsep");
    String fldhd = vars.get("fldhd");

    Integer i = 0; // TODO: test/debugging only
    new File(vars.get("indat")).eachLine('UTF-8') {
        if ((it != null) && (fldhd != null) && (!it.trim().equals(fldhd.trim()))) {
            recLst.add(it.trim());
        } // if
    } // File.eachLine

    // extract relevant parts and feed into Custom SOAP Sampler (registered attachments)
    // csv format:  TMSTMP;PRODID;TENID;FNAM;MDAT
    if (recLst.size() > 0) {
        // empty current attachment list
        // removed the code block as it's throwing an exception

        // create new attachment list
        ArrayList newAtts = new ArrayList();

        for (rec in recLst) {
            String[] flds = rec.split(fldsep);

            def attDef = ctx.getCurrentSampler().getAttachmentDefinition();
            attDef.attachment = new File(flds[3]); 
            attDef.contentID = "flds[0]"; 
            attDef.contentType = "application/pdf"; // one of selections from the dropdown (no PDF listed there)
            attDef.type = 1;                        // 1 = resource, 2 = variable

            newAtts.add(attDef);
        } // for

        if (newAtts.size() > 0) {
            ctx.getCurrentSampler().setAttachments(newAtts);
        } // if
    } // if

In two previous post (initial, round #2) I was faced with an issue with BlazeMeter's step-by-step-debugger plugin, as well as an issue when trying to empty the list of already registered attachments. Now yet another challenge popped into existence.

Exectuing the test plan results in JMeter displaying an error message again.

    Unable to update attachment references, see log files for details.

The jmeter.log file no contains

    <NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>...
    ...<NUL><NUL><NUL><NUL>...
    ...
    2017/04/07 09:21:12 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
    2017/04/07 09:21:12 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
    2017/04/07 09:21:13 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*) 
    2017/04/07 09:21:13 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Number of Users (single key) 
    2017/04/07 09:21:13 INFO  - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Number of Users (single key). 
    2017/04/07 09:21:13 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
    2017/04/07 09:21:13 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false 
    2017/04/07 09:21:13 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
    2017/04/07 09:21:13 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
    2017/04/07 09:21:13 INFO  - jmeter.threads.JMeterThread: Thread started: Number of Users (single key) 1-1 
    2017/04/07 09:21:13 INFO  - jmeter.services.FileServer: Stored: /media/sf_Projects/tstprj/archive/tstdoc.csv 
    2017/04/07 09:21:14 WARN  - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Ignoring invalid attachment: '/media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00000.pdf' 
    2017/04/07 09:21:14 WARN  - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Ignoring invalid attachment: '/media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00001.pdf' 
    2017/04/07 09:21:14 WARN  - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Ignoring invalid attachment: '/media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00002.pdf' 
    2017/04/07 09:21:14 WARN  - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Ignoring invalid attachment: '/media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00003.pdf'
    ...
    2017/04/07 09:21:14 ERROR - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Caught exception while updating attachments javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.2 Message
        at com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPPart1_2Impl.createEnvelopeFromSource(SOAPPart1_2Impl.java:72)
        at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:128)
        at com.jmeter.protocol.soap.sampler.CustomSOAPSampler.updateAttachmentReferences(CustomSOAPSampler.java:448)
        at com.jmeter.protocol.soap.sampler.CustomSOAPSampler.sample(CustomSOAPSampler.java:256)
        at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
        at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
        at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
        at java.lang.Thread.run(Thread.java:745)

    2017/04/07 09:23:00 INFO  - jmeter.threads.JMeterThread: Stopping Thread: org.apache.jorphan.util.JMeterStopThreadException: Unable to update attachment references 
    2017/04/07 09:23:00 INFO  - jmeter.threads.JMeterThread: Stop Thread detected by thread: Number of Users (single key) 1-1 
    2017/04/07 09:23:00 INFO  - jmeter.threads.JMeterThread: Thread finished: Number of Users (single key) 1-1 
    2017/04/07 09:23:00 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
    2017/04/07 09:23:00 INFO  - jmeter.services.FileServer: Close: /media/sf_Projects/tstprj/archive/tstdoc.csv 
    2017/04/07 09:23:00 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*) 

As the drop down list for contentType does not contain application/pdf as an entry, I replaced it with application/gzip, but still to no avail. Regardless of the content type set, it always results in the very same error/log file entries.

One step further but still at a loss, as how to tackle this issue.

My setup comprises:

Sample input csv file

    TMSTMP;PRODID;TENID;FNAM;MDAT
    '20170406112044044970077';'PROD01';'TENANT03';'/media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00000.pdf';'<?xml version=1.0 encoding=UTF-8?><tstpfx:metainformation xmlns:tstpfx=http://my.host.local/tstprj/metainformation_v2.xsd id=000000069496>meta data #01</tstpfx:metainformation>
    '
    '20170406112047030620037';'PROD02';'TENANT01';'/media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00001.pdf';'<?xml version=1.0 encoding=UTF-8?><tstpfx:metainformation xmlns:tstpfx=http://my.host.local/tstprj/metainformation_v2.xsd id=000000069496>meta data #02</tstpfx:metainformation>
    '

This file is getting read twice: (1) by the JSR223 pre-processor to build the attachment list; (2) by the Custom SOAP Sampler, which subsequently iterates over each entry of this file, and passes the relevant bits & bobs to the SOAP Envelop

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tstprj="http://my.host.local/">
       <soapenv:Header/>
       <soapenv:Body>
          <tstprj:archive>
             <product>${PRODID}</product>
             <tenant>${TENID}</tenant>
             <filename>${FNAM}</filename>
             <metadata>${MDAT}</metadata>
             <content>cid:${TMSTMP}</content>
          </tstprj:archive>
       </soapenv:Body>
    </soapenv:Envelope>
spinning10 commented 7 years ago

I will try to deal with your issues in the upcoming days.

spinning10 commented 7 years ago

Not solution but small finding: Replace attDef.contentID = "flds[0]"; with attDef.contentID = flds[0]; Are you sure the File object is created, without exception, out of the path you give? Maybe the apostrophes shouldn't be there.

Sil68 commented 7 years ago

Spotted this already when talking to a colleague, unfortunately didn’t do the trick.

On 9 Apr 2017, at 22:10, Lukasz W notifications@github.com wrote:

Not solution but small finding: Replace attDef.contentID = "flds[0]"; with attDef.contentID = flds[0]; Are you sure the File object is created, without exception, out of the path you give? Maybe the apostrophes shouldn't be there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

spinning10 commented 7 years ago

In order to debug you could add loggers in different places of your script, to make sure that code works till n-th line. I am not sure FILE object is being created out of the path. The sampler was used in Windows environment, maybe some things are different. Your code looks similar to what i used, the only difference is this stage with CSV. You can also check if files from some directory can be attached to the sampler, if this works for you then you can go further and import path to file from csv.

Sil68 commented 7 years ago

Test plan

  1. User Defined Variables;
  2. CSV Data Set Config;
  3. SOAP Request (general);
  4. Number of Users (single record);
    1. Custom SOAP Sampler (specific; single file);
      1. JSR223 PreProcessor (disabled);
  5. View Results in Table;
  6. View Results Tree.

Custom SOAP Sampler

Field Value
Name Custom SOAP Sampler (specific; single file)
URL ${myserver}/${mysvcpath}
Attachment definition
Update ebXMLattachment references in SOAP body disabled/un-ticked
Resource/Value resource
Attachment /media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00000.pdf
Content-type application/pdf
Content ID testdoc-00000.pdf
SOAP Envelop see below

SOAP Envelop

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tstprj="http://my.host.local/">
   <soapenv:Header/>
   <soapenv:Body>
      <tstprj:archive>
         <product>${PRODID}</product>
         <tenant>${TENID}</tenant>
         <filename>${FNAM}</filename>
         <metadata>${MDAT}</metadata>
         <content>cid:${TMSTMP}</content>
      </tstprj:archive>
   </soapenv:Body>
</soapenv:Envelope>

with the variables resolving to

Variable Value
PRODID myproduct
TENID mytenant
FNAM /media/sf_Projects/tstprj/archive/tstdoc/tstdoc-00000.pdf
MDAT metadata
TMSTMP tstdoc-00000.pdf

jmeter.log

Executing this test plan (JSR223 PreProcessor being disabled) results in the following log file entries.

2017/04/10 15:30:58 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
2017/04/10 15:30:58 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2017/04/10 15:30:58 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*) 
2017/04/10 15:30:59 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Number of Users (single key) 
2017/04/10 15:30:59 INFO  - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Number of Users (single key). 
2017/04/10 15:30:59 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
2017/04/10 15:30:59 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=true 
2017/04/10 15:30:59 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
2017/04/10 15:30:59 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2017/04/10 15:30:59 INFO  - jmeter.threads.JMeterThread: Thread started: Number of Users (single key) 1-1 
2017/04/10 15:30:59 INFO  - jmeter.services.FileServer: Stored: /media/sf_Projects/tstprj/archive/tstdoc.csv 
2017/04/10 15:30:59 ERROR - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Exception in SOAP communication com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1331)
at com.jmeter.protocol.soap.sampler.CustomSOAPSampler.sample(CustomSOAPSampler.java:260)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: SOAP exception while trying to externalize: 

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: SOAP exception while trying to externalize: 
at com.sun.xml.internal.messaging.saaj.soap.SOAPIOException.<init>(SOAPIOException.java:58)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:315)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl$1.getInputStream(SOAPPartImpl.java:358)
at javax.activation.DataHandler.writeTo(DataHandler.java:305)
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart.writeTo(MimeBodyPart.java:961)
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart.writeTo(MimeMultipart.java:277)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1322)
at com.jmeter.protocol.soap.sampler.CustomSOAPSampler.sample(CustomSOAPSampler.java:260)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.2 Message
at com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPPart1_2Impl.createEnvelopeFromSource(SOAPPart1_2Impl.java:72)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:128)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:310)
... 10 more

CAUSE:

javax.xml.soap.SOAPException: InputStream does not represent a valid SOAP 1.2 Message
at com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPPart1_2Impl.createEnvelopeFromSource(SOAPPart1_2Impl.java:72)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:128)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getContentAsStream(SOAPPartImpl.java:310)
at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl$1.getInputStream(SOAPPartImpl.java:358)
at javax.activation.DataHandler.writeTo(DataHandler.java:305)
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeBodyPart.writeTo(MimeBodyPart.java:961)
at com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart.writeTo(MimeMultipart.java:277)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1322)
at com.jmeter.protocol.soap.sampler.CustomSOAPSampler.sample(CustomSOAPSampler.java:260)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
at java.lang.Thread.run(Thread.java:745)

2017/04/10 15:30:59 INFO  - jmeter.threads.JMeterThread: Stop Thread seen for thread Number of Users (single key) 1-1, reason:org.apache.jorphan.util.JMeterStopThreadException: End of file:/media/sf_Projects/tstprj/archive/tstdoc.csv detected for CSV DataSet:CSV Data Set Config configured with stopThread:true, recycle:false 
2017/04/10 15:30:59 INFO  - jmeter.threads.JMeterThread: Thread finished: Number of Users (single key) 1-1 
2017/04/10 15:30:59 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2017/04/10 15:30:59 INFO  - jmeter.services.FileServer: Close: /media/sf_Projects/tstprj/archive/tstdoc.csv 
2017/04/10 15:30:59 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*) 

After having successfully carried out the first few steps, an error message occurs.

2017/04/10 15:30:59 ERROR - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Exception in SOAP communication com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Error during saving a multipart message

There is only the Custom SOAP Sampler, no groovy/JSR223 pre-processing script so far.

Sil68 commented 7 years ago

JMeter plugins

Might it be that I'm missing some plug-ins which are installed at your end?

jmeter/lib/ext

Column #1 Column #2
ApacheJMeter_components.jar jmeter-plugins-filterresults-2.1.jar
ApacheJMeter_core.jar jmeter-plugins-functions-2.0.jar
ApacheJMeter_ftp.jar jmeter-plugins-graphs-additional-2.0.jar
ApacheJMeter_functions.jar jmeter-plugins-graphs-basic-2.0.jar
ApacheJMeter_http.jar jmeter-plugins-graphs-composite-2.0.jar
ApacheJMeter_java.jar jmeter-plugins-graphs-dist-2.0.jar
ApacheJMeter_jdbc.jar jmeter-plugins-graphs-ggl-2.0.jar
ApacheJMeter_jms.jar jmeter-plugins-graphs-vs-2.0.jar
ApacheJMeter_junit.jar jmeter-plugins-httpraw-0.1.jar
ApacheJMeter_ldap.jar jmeter-plugins-jms-0.2.jar
ApacheJMeter_mail.jar jmeter-plugins-jmxmon-0.2.jar
ApacheJMeter_mongodb.jar jmeter-plugins-json-2.6.jar
ApacheJMeter_monitors.jar jmeter-plugins-lockfile-0.1.jar
ApacheJMeter_native.jar jmeter-plugins-manager-0.12.jar
ApacheJMeter_ssh-1.1.1-SNAPSHOT.jar jmeter-plugins-mergeresults-2.1.jar
ApacheJMeter_tcp.jar jmeter-plugins-pde-0.1.jar
CustomSoapSampler-1.3.jar jmeter-plugins-perfmon-2.1.jar
jmeter-debugger-0.3.jar jmeter-plugins-plancheck-2.2.jar
jmeter-plugins-autostop-0.1.jar jmeter-plugins-prmctl-0.3.jar
jmeter-plugins-casutg-2.1.jar jmeter-plugins-rotating-listener-0.1.jar
jmeter-plugins-cmd-2.1.jar jmeter-plugins-senseuploader-2.4.jar
jmeter-plugins-csl-0.1.jar jmeter-plugins-synthesis-2.1.jar
jmeter-plugins-csvars-0.1.jar jmeter-plugins-table-server-2.2.jar
jmeter-plugins-dbmon-0.1.jar jmeter-plugins-tst-2.0.jar
jmeter-plugins-directory-listing-0.1.jar jmeter-plugins-wsc-0.1.jar
jmeter-plugins-dummy-0.2.jar jmeter-plugins-xml-0.1.jar
jmeter-plugins-ffw-2.0.jar JMeterWebSocketSampler-1.0.2-SNAPSHOT.jar
jmeter-plugins-fifo-0.2.jar jmeter-wssecurity-1.2.jar

jmeter/lib

Column #1 Column #2
accessors-smart-1.1.jar jodd-props-3.7.1.jar
ApacheJMeter_slf4j_logkit.jar jorphan.jar
asm-5.1.jar jsch-0.1.50.jar
avalon-framework-4.1.4.jar json-path-2.2.0.jar
bsf-2.4.0.jar json-smart-2.2.1.jar
bsh-2.0b5.jar jsoup-1.10.1.jar
bshclient.jar jtidy-r938.jar
cmdrunner-2.0.jar junit-4.12.jar
commons-codec-1.10.jar logkit-2.0.jar
commons-collections-3.2.2.jar mail-1.5.0-b01.jar
commons-dbcp2-2.1.1.jar mongo-java-driver-2.11.3.jar
commons-httpclient-3.1.jar oro-2.0.8.jar
commons-io-2.5.jar perfmon-2.2.2.jar
commons-jexl-2.1.1.jar ph-commons-6.2.4.jar
commons-jexl3-3.0.jar ph-css-4.1.6.jar
commons-lang3-3.5.jar qpid-client-0.20.jar
commons-logging-1.2.jar qpid-common-0.20.jar
commons-math3-3.6.1.jar rhino-1.7.7.1.jar
commons-net-3.5.jar rsyntaxtextarea-2.6.0.jar
commons-pool2-2.4.2.jar serializer-2.7.2.jar
dnsjava-2.1.7.jar slf4j-api-1.7.21.jar
excalibur-logger-1.1.jar spring-core-2.5.6.jar
freemarker-2.3.23.jar spring-jms-2.5.6.jar
geronimo-jms_1.1_spec-1.1.1.jar tika-core-1.14.jar
groovy-all-2.4.7.jar tika-parsers-1.14.jar
hamcrest-core-1.3.jar websocket-api-9.1.1.v20140108.jar
httpclient-4.5.2.jar websocket-client-9.1.1.v20140108.jar
httpcore-4.4.5.jar websocket-common-9.1.1.v20140108.jar
httpmime-4.5.2.jar wss4j-ws-security-common-2.1.8.jar
jcharts-0.7.5.jar wss4j-ws-security-dom-2.1.8.jar
jetty-http-9.1.1.v20140108.jar xalan-2.7.2.jar
jetty-io-9.1.1.v20140108.jar xercesImpl-2.11.0.jar
jetty-util-9.1.1.v20140108.jar xml-apis-1.4.01.jar
jmeter-plugins-cmn-jmeter-0.3.jar xmlgraphics-commons-2.1.jar
jmeter-plugins-common-io-0.2.jar xmlpull-1.1.3.1.jar
jodd-core-3.7.1.jar xmlsec-2.0.8.jar
jodd-lagarto-3.7.1.jar xpp3_min-1.1.4c.jar
jodd-log-3.7.1.jar xstream-1.4.9.jar
spinning10 commented 7 years ago

Standart JMeter was enough for running Custom Soap Plugin

spinning10 commented 7 years ago

Do you get request sent when you attach file to attachments and soap body in UI? If yes then

Sil68 commented 7 years ago

Great! At least I’m not missing a vital component! — One more ticked off on the list to verify. :)

On 10 Apr 2017, at 16:27, Lukasz W notifications@github.com wrote:

Standart JMeter was enough for running Custom Soap Plugin

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Sil68 commented 7 years ago

Yes, indeed it does, albeit I’m receiving some kind of an error message (will provide tomorrow, when I’m back).

On 10 Apr 2017, at 17:48, Lukasz W notifications@github.com wrote:

Do you get request sent when you attach file to attachments and soap body in UI? If yes then

• do you get request sent when you do it programatically, you can send just soap body, then you can try with attachment Try to check step by step and narrow down the problem. From top level perspective i didn't see issue in your code. I was using similar script, but it was making File object based on absolute path to file. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Sil68 commented 7 years ago

View Results in Table

Sample # Start Time Thread Name Label Sample Time(ms) Status Bytes Sent Bytes Latency Connect Time(ms)
1 08:36:11.436 Number of Users (single key) Custom SOAP Sampler (specific; single file) 403 failed 0 0 0 0
2 08:36:20.978 Number of Users (single key) Custom SOAP Sampler (specific; single file) 40 failed 0 0 0 0

View Results Tree

Sample #1

Thread Name: Number of Users (single key) 1-1
Sample Start: 2017-04-11 08:36:11 CEST
Load time: 403
Connect Time: 0
Latency: 0
Size in bytes: 0
Sent bytes:0
Headers size in bytes: 0
Body size in bytes: 0
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): 
Response code: SOAPException
Response message: Error during saving a multipart message

Response headers:

SOAPSampleResult fields:
ContentType: 
DataEncoding: null

Sample #2

Thread Name: Number of Users (single key) 1-1
Sample Start: 2017-04-11 08:36:20 CEST
Load time: 40
Connect Time: 0
Latency: 0
Size in bytes: 0
Sent bytes:0
Headers size in bytes: 0
Body size in bytes: 0
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): 
Response code: SOAPException
Response message: Error during saving a multipart message

Response headers:

SOAPSampleResult fields:
ContentType: 
DataEncoding: null
spinning10 commented 7 years ago

Maybe your system does not accept the message or has a bug. Check by sending request by using UI of the JMeter, look what is displayed in the 'Results in a tree' for request and response tab. Alternatively you can see what is the request being sent to system by using Wireshark or Fiddler type of tool. This also looks weird in the samples you sent: "Data type ("text"|"bin"|""): "

Sil68 commented 7 years ago

The message is actually one which has been deployed and is facilitated by various clients for quite a fair number of years now. Using SOAP UI renders the expected result.

spinning10 commented 7 years ago

Ok, do you fill in url and body before doing attachments enclosing? Because programmatically only this part of operation is being applied. Send a single request from sample by using UI, just one valid attachment, valid url, body, everything as happy path.

Sil68 commented 7 years ago

Please see enclosed screenshot as how I fill the Custom SOAP Sampler form prior to executing the test plan. custom soap sampler

spinning10 commented 7 years ago

It's not yet answer to the issue but you can set request body programmatically like that: ctx.getCurrentSampler().setXmlData(xmlMessage);

I was trying the sampler in my environment and all works fine. I guess that for some reason you don't specify valid path to attachments but this can be really anything. Any kind of exception (I simulated lack of directory to be cleaned, lack of cerificate) results in the same generic exception: "error during saving multipart data". Analyse step by step which line in the JSR223Preprocessor causes an exception. I checked the sampler with request that does not use attachments and didn't get that exception if directory with attachment was not existing (simply because script wasn't looking for it there so did not cause exception).

Sil68 commented 7 years ago

You mean Ill just grab the soap envelop currently defined in the Custom SOAP Sampler, put it into my pre-processor script (as one single string?), and have the pre-processor fill in the xml code by means of the function/method mentioned by you? Is it a reasonable thing to do to remove to xml code from the sampler config?

On 12 Apr 2017, at 00:27, Lukasz W notifications@github.com wrote:

It's not yet answer to the issue but you can set requet body programmatically like that: ctx.getCurrentSampler().setXmlData(xmlMessage);

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

spinning10 commented 7 years ago

First sentence was only extra information. Focus on second part. Remotely difficult to help more.

Sil68 commented 7 years ago

I reckon, as I'm selecting the attached file from within JMeter, from within the Custom SOAP Sampler by means of the Browse button, the file path is deemed to be a valid one?

As mentioned earlier, I've completely de-activated the JSR223 ProProcessor, and I'm trying to execute the SOAP request for uploading the manually (via the GUI) attached file solely by the sampler.

I'm completely at a loss here.

spinning10 commented 7 years ago

Yes, path has to be valid. Check first without attachment, just only body and valid URL to server, then add new items only after previous success.

Sil68 commented 7 years ago

Might it be the case that, at least under linux, the sampler is facing an issue if there's a space character somewhere inside the file path?

spinning10 commented 7 years ago

it is possible, I haven't used JMeter sampler on Linux. Check first with attachment that is placed in "simple" path without special characters. Or select attachment using the browser popup that opens and select in "by click".

Sil68 commented 7 years ago

Moving the document to the file system root, selecting this file then by means of the "BROWSE" button located inside the Custom SOAP Sampler renders the very same result:

ERROR - com.jmeter.protocol.soap.sampler.CustomSOAPSampler: Exception in SOAP communication com.sun.xml.internal.me
ssaging.saaj.SOAPExceptionImpl: Error during saving a multipart message
spinning10 commented 7 years ago

Ok then. So maybe there is a bug with linux system. Wasn't used there and I wasnt aware it may be an issue. I will deal with it since Tuesday next week. Apologies and I ask for patience.

Sil68 commented 7 years ago

I've now copied the SOAP envelop from another (already successfully working) test plan, facilitating the regular HTTP/SOAP Request/Sampler, and injected into the Custom SOAP Sampler, and it failed.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tstprj="http://my.host.local/">
   <soapenv:Header/>
   <soapenv:Body>
      <tstprj:getMetadata>
         <product>${PRODID}</product>
         <tenant>${TENID}</tenant>
         <key>${KEY}</key>
      </tstprj:getMetadata>
   </soapenv:Body>
</soapenv:Envelope>

(just reading from the web service, no writing, no uploading)

The service URL in the regular HTTP/SOAP Request/Sampler comprises of ${myserver} for Server Name or IP and ${mysvcpath} for Path (no explicit specification of any protocol anywhere!), whereas the Custom SOAP Sampler's service URL reads ${myserver}/${mysvcpath} (again no explicit specification of any protocol anywhere!).

View Results Tree contains

Thread Name: Number of Users (single key) 1-1
Sample Start: 2017-04-13 16:23:14 CEST
Load time: 5
Connect Time: 0
Latency: 0
Size in bytes: 0
Sent bytes:0
Headers size in bytes: 0
Body size in bytes: 0
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): 
Response code: SOAPException
Response message: Error during saving a multipart message

Response headers:

SOAPSampleResult fields:
ContentType: 
DataEncoding: null
Sil68 commented 7 years ago

No worries, Lukasz; glad that I’m able to help testing a bit! :)

And thanks for your support!

On 13 Apr 2017, at 16:08, Lukasz W notifications@github.com wrote:

Ok then. So maybe there is a bug with linux system. Wasn't used there and I wasnt aware it may be an issue. I will deal with it since Tuesday next week. Apologies and I ask for patience.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

spinning10 commented 7 years ago

Hi What do you mean by: "(just reading from the web service, no writing, no uploading)" Did you manage to send plain request without attachment, with hardcoded envelope, url and by using Custom Soap Sampler? We don't care about response too much yet, but just to get the request sent and some http code returned by the server

Sil68 commented 7 years ago

Hi,

Basically I’m trying to connect to two different types of web services:

:: one to retrieve data from the server; :: one to upload data to the server.

Neither of these two I managed to successfully execute using “Custom SOAP Sampler”.

If replacing this sampler with a “regular” http request sampler, I successfully can pull data from the server, and if hard-coding base64-encoded documents into the SOAP envelop, I even managed to successfully upload data to the server; but as said, only the vanilla http sampler bundled with JMeter.

On 18 Apr 2017, at 19:35, Lukasz W notifications@github.com wrote:

Hi What do you mean by: "(just reading from the web service, no writing, no uploading)" Did you manage to send plain request without attachment, with hardcoded envelope, url and by using Custom Soap Sampler? We don't care about response too much yet, but just to get the request sent and some http code returned by the server

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

spinning10 commented 7 years ago

Ok, today I will run JMeter with my Custom Sampler on Linux system and see what happens. I didn't ask what java you have on your machine, if 1.8 it should be fine. If 1.7 also ok, but you can check it as well, to eliminate basic obstacles. Problem for me seems at the essential level, because the message does not even get sent. Internal exception in the sampler occurs and there is "error at multipart message' information, that is rather generic.

Sil68 commented 7 years ago

My linux box is sporting Ubuntu 17.04 with Oracle JDK 1.8 (installed via apt-get)

On 19 Apr 2017, at 11:42, Lukasz W notifications@github.com wrote:

Ok, today I will run JMeter with my Custom Sampler on Linux system and see what happens. I didn't ask what java you have on your machine, if 1.8 it should be fine. If 1.7 also ok, but you can check it as well, to eliminate basic obstacles. Problem for me seems at the essential level, because the message does not even get sent. Internal exception in the sampler occurs and there is "error at multipart message' information, that is rather generic.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

spinning10 commented 7 years ago

We have tried on UBuntu Linux and in managed to get the sampler working. The initial issue was that Linux is case-sensitive in paths, so this had to be adjusted. Make sure you can load all the files with data to object when using groovy (certificates, attachments, soap envelope). Are you using https? If yes make sure to use proper certificate and its password in groovy (can be also set in bin/system.properties). Soap envelope is being set in groovy like this: "ctx.getCurrentSampler().setXmlData(signedMessage);", but I was sending it.

If you are not afraid you can send your project and we would check it next week, why doesn't work. You can change on purpose some content-sensitive data, but to keep the structure and project resembling yours. In my own groovy script I was doing quite many operations like unzipping, values replacement, message signing with WSS4j, and didn't have any issues on Linux.

Remotely it's difficult to help. Please make sure you can first load the soap envelope, then attachments and you can compose the request. In your case you get exception at the very beginning, which means there is no message flow over the wire at all. Maybe it is something simple like incorrect path regarding case sensitivity, maybe the certificate for https.

Sil68 commented 7 years ago

Is it possible to download the most recent version to the sampler, in order for to try it out without any groovy script/pre-processor at all?

No, there's no https (yet), just plain http.

spinning10 commented 7 years ago

This is the latest sampler version. groovy/script is the other component, not coming along with sampler. Sampler can be used just directly from the UI, where URL, attachments, message body is placed in UI boxes. Try using it the simplest way, with no scripting first and observe the logs.

spinning10 commented 7 years ago

I didn't get new feedback and testd the sampler in Linux system which resulted in finding no issue. Unable to recreate.

Sil68 commented 7 years ago

Hi Lukasz,

Thanks a bunch for your support & effort!

As we were running on a tight time line I had to come up with an alternative solution, namely creating b64 encoded variants of the test files, and uploading these by facilitating the JMeter csv import module.

We’ve tried out the updated version of your module subsequently and I can confirm our issue seems to have been resolved.

Best, Martin

On 27 Jun 2017, at 15:12, Lukasz W notifications@github.com wrote:

I didn't get new feedback and testd the sampler in Linux system which resulted in finding no issue. Unable to recreate.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.