Am 24.11.2016 um 17:51 schrieb Eddie O'Sullivan:
Hi Felix,
I got this working by doing the following:
Great to hear.
- Set Variables I wanted to change in the dataset
- Req 1 - GET. I stored the response in a JMeter variable via a regular
expression
If the response is XML, you could have a look at the xpath extractor. It
might be easier and less error prone.
- Beashell code to dynamically change the Nodes in the XML to my JMeter
Variable values storing the results in the JMeter variable extracted from
Req1
As JMeter includes groovy as a JSR223 language, you could that groovy
power to manipulate XML snippets with it. For example (as attached):
import groovy.xml.XmlUtil
def personOne = new XmlParser().parseText(vars.get('personOne'))
personOne.value = 'Changed'
vars.put('personOneChanged', XmlUtil.serialize(personOne))
Where the var personOne was extracted from the xml snippet
<root><person id="1">Joe</person><person id="2">Jane</person></root>
with the xpath
//person[@id='1'] and placed in the var named 'personOne'
- Req 2 - Send my updated JMeter Variable to the Post
That should be easy.
I don't know if it is faster than your solution, but I guess it looks
simpler.
Regards,
Felix
Regards,
Eddie
On 19 November 2016 at 19:41, Felix Schumacher <
[email protected]> wrote:
Am 18.11.2016 um 12:59 schrieb Eddie O'Sullivan:
Hi all,
We are looking to do some SOAP WSDL testing using JMeter. The scenario we
are trying to cover is as follows:
1. Req1 - GET request that returns and XML file (this may change over
time but the nodes we are interested in remain the same)
2. Modify the XML changing the values
3. Req2 - POST the modified XML into a Request
Modifying the XML can be achieved relatively easily in SOAPUI using the
Property Transfer but we would rather stick to JMeter.
So you get a xml result, from which you want to keep some node (with its
sub-nodes) and modify that, by replacing some pre-known values with other
values?
The property transfer looked to me to be more like: Get a xml result.
Extract values from it into properties and use those to modify some
pre-known answer xml.
The latter workflow can be modelled by post-processors and usage of JMeter
variables.
Do you really need the former?
Regards,
Felix
Are there any plugins or suggestions on an easy way that the XML response
can be manipulated before sending in a subsequent request?
Thanks in advance,
Eddie
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="3.1" jmeter="3.1-SNAPSHOT.20161127">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Testplan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="Benutzer definierte Variablen" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread-Gruppe" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Schleifen-Controller (Loop Controller)" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<stringProp name="LoopController.loops">1</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<longProp name="ThreadGroup.start_time">1480244672000</longProp>
<longProp name="ThreadGroup.end_time">1480244672000</longProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<JavaSampler guiclass="JavaTestSamplerGui" testclass="JavaSampler" testname="Java Anfrage (Request)" enabled="true">
<elementProp name="arguments" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="Sleep_Time" elementType="Argument">
<stringProp name="Argument.name">Sleep_Time</stringProp>
<stringProp name="Argument.value">100</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="Sleep_Mask" elementType="Argument">
<stringProp name="Argument.name">Sleep_Mask</stringProp>
<stringProp name="Argument.value">0xFF</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="Label" elementType="Argument">
<stringProp name="Argument.name">Label</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="ResponseCode" elementType="Argument">
<stringProp name="Argument.name">ResponseCode</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="ResponseMessage" elementType="Argument">
<stringProp name="Argument.name">ResponseMessage</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="Status" elementType="Argument">
<stringProp name="Argument.name">Status</stringProp>
<stringProp name="Argument.value">OK</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="SamplerData" elementType="Argument">
<stringProp name="Argument.name">SamplerData</stringProp>
<stringProp name="Argument.value"></stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
<elementProp name="ResultData" elementType="Argument">
<stringProp name="Argument.name">ResultData</stringProp>
<stringProp name="Argument.value"><root><person id="1">Joe</person><person id="2">Jane</person></root></stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="classname">org.apache.jmeter.protocol.java.test.JavaTest</stringProp>
</JavaSampler>
<hashTree>
<XPathExtractor guiclass="XPathExtractorGui" testclass="XPathExtractor" testname="XPath Extractor" enabled="true">
<stringProp name="XPathExtractor.default"></stringProp>
<stringProp name="XPathExtractor.refname">personOne</stringProp>
<stringProp name="XPathExtractor.xpathQuery">//person[@id='1']</stringProp>
<boolProp name="XPathExtractor.validate">false</boolProp>
<boolProp name="XPathExtractor.tolerant">false</boolProp>
<boolProp name="XPathExtractor.namespace">false</boolProp>
<boolProp name="XPathExtractor.fragment">true</boolProp>
</XPathExtractor>
<hashTree/>
<JSR223PostProcessor guiclass="TestBeanGUI" testclass="JSR223PostProcessor" testname="JSR223 PostProcessor" enabled="true">
<stringProp name="cacheKey">c8e8befd-0e7d-4ce1-9ed4-eed6a77f6481</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="script">import groovy.xml.XmlUtil
def personOne = new XmlParser().parseText(vars.get('personOne'))
personOne.value = 'Changed'
vars.put('personOneChanged', XmlUtil.serialize(personOne))</stringProp>
<stringProp name="scriptLanguage">groovy</stringProp>
</JSR223PostProcessor>
<hashTree/>
</hashTree>
<DebugSampler guiclass="TestBeanGUI" testclass="DebugSampler" testname="Debug Sampler" enabled="true">
<boolProp name="displayJMeterProperties">false</boolProp>
<boolProp name="displayJMeterVariables">true</boolProp>
<boolProp name="displaySystemProperties">false</boolProp>
</DebugSampler>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]