Bug 39252 - Set SoapSampler to set sample result with XmlData
Summary: Set SoapSampler to set sample result with XmlData
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-08 02:08 UTC by sumit shah
Modified: 2006-04-14 14:37 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sumit shah 2006-04-08 02:08:26 UTC
Would it be possible to modify SoapSampler.java to set the Sampler Data of the
SampleResult to XmlData provided by the GUI?  This would involve changing the
last few lines of th e
public SampleResult sample(Entry e) method to :

	public SampleResult sample(Entry e) {
    URL url = null;
    try {
			url = new URL(getURLData());
			setDomain(url.getHost());
			setPort(url.getPort());
			setProtocol(url.getProtocol());
			setMethod(POST);
			if (url.getQuery() != null && url.getQuery().compareTo("") != 0) {
				setPath(url.getPath() + "?" + url.getQuery());
			} else {
				setPath(url.getPath());
			}
			// make sure the Post header is set
			URLConnection conn = url.openConnection();
			setPostHeaders(conn);
		} catch (MalformedURLException e1) {
			log.error("Bad url: " + getURLData(), e1);
		} catch (IOException e1) {
			log.error("Bad url: " + getURLData(), e1);
		}
		HTTPSampleResult result = (HTTPSampleResult)super.sample(e);
    result.setDataType(SampleResult.TEXT);
    if(url != null) {
      result.setSamplerData("\n" + getXmlData());
    }
    return result;
  }
Comment 1 Sebb 2006-04-10 01:47:56 UTC
Thanks for the suggestion - it has been included in the 2.1 branch code, and
will be included in JMeter 2.1.2.

If you want to give it a try, the nightly 2-1.20060410 has the fix included.
Comment 2 sumit shah 2006-04-13 15:25:16 UTC
Hi, Thanks for applying the patch, but it seems like it the patch I submitted
does not work against the current nightly builds.  I had tested it against 2.1.1
release.  The following fix I think in the  public SampleResult sample(Entry e)
should be changed to:

// Bug 39252 set SoapSampler sample result from XML data
/*
SampleResult sampleResult = super.sample(e);
sampleResult.setDataType(SampleResult.TEXT);
sampleResult.setSamplerData(getXmlData());
return sampleResult;
*/
HTTPSampleResult result = (HTTPSampleResult)super.sample(e);
result.setDataType(SampleResult.TEXT);
result.setSamplerData("\n" + getXmlData());
result.setQueryString("\n" + getXmlData());
return result;
Comment 3 Sebb 2006-04-13 16:08:26 UTC
(In reply to comment #2)
> Hi, Thanks for applying the patch, but it seems like it the patch I submitted
> does not work against the current nightly builds.  I had tested it against 
2.1.1
> release.  The following fix I think in the  public SampleResult sample(Entry 
e)
> should be changed to:
> // Bug 39252 set SoapSampler sample result from XML data
> /*
> SampleResult sampleResult = super.sample(e);
> sampleResult.setDataType(SampleResult.TEXT);
> sampleResult.setSamplerData(getXmlData());
> return sampleResult;
> */
> HTTPSampleResult result = (HTTPSampleResult)super.sample(e);
> result.setDataType(SampleResult.TEXT);
> result.setSamplerData("\n" + getXmlData());

The above has been done (but I removed the \n prefix)

> result.setQueryString("\n" + getXmlData());

This was not done, as it was not asked for - see your original posting.

Why do you need both set to the same value?

> return result;
Comment 4 sumit shah 2006-04-13 16:13:55 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > HTTPSampleResult result = (HTTPSampleResult)super.sampe(e);
> > result.setDataType(SampleResult.TEXT);
> > result.setSamplerData("\n" + getXmlData());
> 
> The above has been done (but I removed the \n prefix)
> 
> > result.setQueryString("\n" + getXmlData());
> 
> This was not done, as it was not asked for - see your original posting.
> 
> Why do you need both set to the same value?
> 

I'm not sure, but it only worked in the nightlies when I coded it as above.

Thanks
Comment 5 Sebb 2006-04-13 18:37:33 UTC
OK, I've found the problem.

The HTTPSample assumes that POST data is stored in the QueryString (dunno 
why); and when it overrides getSampleData it ignores samplerData entirely, so 
the information is not shown in the Tree View pane.

This probably needs tidying up a bit; in the meanwhile, I've saved the data to 
the query string as well.

Perhaps you could now try the new nightly?
Also, please check that the correct information is being written to the JTL 
files
Comment 6 sumit shah 2006-04-14 21:37:41 UTC
(In reply to comment #5)
> OK, I've found the problem.
> 
> The HTTPSample assumes that POST data is stored in the QueryString (dunno 
> why); and when it overrides getSampleData it ignores samplerData entirely, so 
> the information is not shown in the Tree View pane.
> 
> This probably needs tidying up a bit; in the meanwhile, I've saved the data to 
> the query string as well.
> 
> Perhaps you could now try the new nightly?
> Also, please check that the correct information is being written to the JTL 
> files

I tried out the new nightly it looks correct.  Thanks a lot!
Comment 7 The ASF infrastructure team 2022-09-24 20:37:36 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1708