HTTP GET, retrive values from an xml
and than I need to call a PUT many times as the number of element with some values I got from the first GET.
I have an xml for example
<root>
<element>
<valId>1111</valId>
<valName>Name</valName>
</element>
<element>
<valId>1111</valId>
<valName>Name</valName>
</element>
....
</root>
So I have:
HTTP GET: retrive an xml
xpath extractor 1 for valsId
xpath extractor 2 for valsName
Now I have two array with multiple values in valId and valName, I can access to them with valsId_1, valsId_2, etc
Then I have a foreach controller in input I have valsId and output the current value myId.
as child of foreach controller I have my http PUT where I use myId but I don't know how to get the current value of valsName.
In my opinion for this kind of problem there two way:
1 extract the values in array, as I did
2 extract a part of xml and than process it everytime in a for
I hope you understand what I meant with my problem.
Any suggestions are welcome
For handling second variable "valsName" just place below code
${__BeanShell(vars.get("valsName_"+${__counter(TRUE,page)}))}
at the position of Name
<valName>Name</valName>
it'll resolve your problem.
Related
I am trying to read attribute value which is within a CDATA from XML in Talend. I am getting the value along with CDATA and not the value alone.
My XML format is :
<root>
<node attribute="![CDATA[value]]" />
</root>
In Xpath if i give attribute it is retrieving the value as ![CDATA[value]]. I want to get only "value". Is it possible to get the value inside the CDATA?
tMap or tJavaFlex set output value as:
row1.value.replaceAll("!\\[CDATA\\[","").replaceAll("\\]\\]","")
row1.value - change for You real name
I am performing load testing on my server using jmeter.
In one of my post requests, I receive a unique id in the response.
I need to send this id as a parameter in the following post requests.
I am new to jmeter and don't have any idea how to do this.
Help would be really appreciated.
If you need to store the whole response into a variable - take the following steps:
Add Beanshell PostProcessor as a child of the request which returns response you're looking for
Put the following line into the PostProcessor's "Script" area:
vars.put("response", new String(data));
Refer extracted value as ${response} where required
See How to Use BeanShell: JMeter's Favorite Built-in Component guide to lean more about Beanshell scripting in JMeter
Alternatively you can do the same with the Regular Expression Extractor, in that case relevant configuration will be:
Reference Name: response
Regular Expression: (?s)(^.*)
Template: $1$
If you need a part of response, not the whole response you can amend Regular Expression according to your needs as per Regular Expressions chapter of JMeter's User Manual
If you really need to store the whole response into a variable, do the following:
Add JSR223 PostProcessor as a child of the request which returns response you're looking for
Put the following line into the "Script" area:
vars.put("response", prev.getResponseDataAsString());
Use then this response as ${response} where you need it
But you rarely need to use the whole response and you should avoid it for big , in this case it is much better to use the Extractor that suits your response format:
JSON Extractor for JSON
CSS/JQuery Extractor for HTML extraction
XPath Extractor for XML
Regular Expression Extractor for all of them or any textual format
You can use JMeter's Post-Processor Regular Expression Extractor to extract the required value from response. Just Add this under the sampler whose response will contain the required value.
In Reg expression extractor, you will define the variable name (referenceName), RegularExpression, template etc. Later you can use the value in this variable. To learn how to use Reg expression extractor you can refer to following tutorial.
https://docs.blazemeter.com/customer/portal/articles/1743642-using-regex-regular-expression-extractor-with-jmeter
I know this question is old but I agree with #UBIK you should probably use a JSON extractor. I am working with a load test that is sending over 100 requests per second and I need to reuse the value in a specific JSON key, so I'm using a JSON extractor and saving the values in a .csv file to be used by the next request.
extract the JSON
This is the Groovy script to write it to a .csv file
def myRandomIds = new File("randomIds.csv")
myRandomIds << vars.get("id") + ","
myRandomIds << System.getProperty("line.separator")
log.info(vars.get("id") + " saved to randomIds.csv...")
This is the CSV data config I have set up in my other request that is reading from the csv file. (In my case these .jmx files are automated and parametized using jenkins)
CSV data set config
I'm trying to parse an XML using TBXML and everything is going fine except for tags which contain special characters in their value.
For example, consider the XML element
<tag> sources/data </tag>
I'm trying to get the text sources/data from this tag. I'm using [TBXML textForElement:element] to achieve this. But it always returns an empty string.
The same code fails for another tag which is defined as :
<tag> array[i] </tag>.
But it works fine for normal text values like
<tag>name</tag>.
Can anyone help me out here ?
Quote: "Because XML syntax uses some characters for tags and attributes it is not possible to directly use those characters inside XML tags or attribute values."
http://www.dvteclipse.com/documentation/svlinter/How_to_use_special_characters_in_XML.3F.html
As I know this kind of data must be in placed CDATA.
I am trying to use a typeahead functionality within an inputtext-field.
Instead of populating the values by using a fixed list or a DBColumn (which is way to slow for more than thousands of entries), I would like to use the url parameter of the typeahead properties.
What I have done so far is that:
<xp:inputText value="#{docEntry.namUsers}" id="namUsers">
<xp:typeAhead mode="external" valueMarkup="false" minChars="3" var="namEntries" frequency="1" maxValues="10" id="typeAheadNamUsers">
<xp:this.url><![CDATA[#{javascript:"http://server/databse.nsf/view?ReadViewEntries&OutputFormat=JSON&StartKey=" + getComponent("namUsers").getAttributes().get("value");}]]></xp:this.url>
</xp:typeAhead>
</xp:inputText>
When entering the minimum required characters I can see that a GET-request is fired. And this GET-request returns the desired content of the view.
But I didn't find any way to fetch the returned information in order to parse the content and give a valid list to the typeahead element.
Has anyone tried using the url property of the typeahead element?
You cannot use the url parameter of the typeahead this way. The parameter is only a configuration parameter for the initialisation of the typeahead widget and will not get updated with your server side code.
If you look in the firebug console you can see that there is an URL parameter named $$value which is automatically added to the url you have defined (containing the characters for the lookup itself).
The response for the Typeahead needs to be simple HTML code:
<ul>
<li>Result 1</li>
<li>Result 2</li>
<li>Result 3</li>
<li>...</li>
</ul>
[It can be changed for display purposes, but it needs to be HTML]
There is no JSON / no XML for external requests.
You could create a $$ViewTemplate (HTML content) for your view to return the required format, and f.e. add a redirection agent:
Option Public
Option Declare
Sub Initialize
Dim session As New NotesSession
Dim doc As NotesDocument
Dim hlp
Set doc = session.Documentcontext
hlp = Split( doc.QUERY_STRING_DECODED(0), "$$value=" )
Print "[http://example.com/YourDB.nsf/View?OpenView&startKey=" & hlp(1) & "]"
End Sub
Then you can set the url to your Agent instead to the view:
<xp:typeAhead mode="external" valueMarkup="false" minChars="3"
frequency="1" maxValues="10" id="typeAheadNamUsers"
url="http://example.com/YourDB.nsf/RedirectAgent?OpenAgent">
</xp:typeAhead>
AFAIK the data expected from that URL needs to be "collection ready", meaning a list of values separated by a delimiter (comma or newline). ?ReadViewEntries doesn't deliver that format, so you want to use a HTML passthru view instead.
I would challenge you assumption. If your database for the lookup is on the same server, what makes you presume that adding HTTP latency will be faster than a #DbColumn? If it is a different server it would be an interesting test -- besides it would be better anyhow to keep the value lookup on the same server.
Another question: is the user experience with thousands of potential values in a typeahead list really what is efficient, effective and pleasant?
I have this data (all the elements are optional):
<data>
<optionalElement1>...</optionalElement1>
<optionalElement2>...</optionalElement2>
<optionalElement3>...</optionalElement3>
</data>
I need to map this to another schema (all the elements are required):
<request>
<Element1>...</Element1>
<Element2>...</Element2>
<Element3>...</Element3>
</request>
Since the elements in the original request are optional, the mapping will
only generate the corresponding elements for the originally included
elements. But the validation of the request will fail.
Example:
<data>
<optionalElement3>
<value1>1</value1>
<value2>2</value2>
</optionalElement3>
</data>
will be mapped to
<request>
<Element3>
<subelement1>1</subelement1>
<subelement2>2</subelement2>
</Element3>
</request>
And the validation will fail because i'm missing Element1 and Element2. The
response should be (I think):
<request>
<Element1 xsi:nil="true" />
<Element2 xsi:nil="true" />
<Element3>
<subelement1>1</subelement1>
<subelement2>2<subelement2>
</Element3>
</request>
How can I do this in the mapping? How can I ensure that the element is
created in the output message?
And, by the way, if a subelement is not present (let's say
"data/optionalElement1/value1" how can I make sure that the destination
subelement "request/Element1/subelement1" is created?
Make it very simple. Use the xlst file for mapping.
Using simple if condition you can check for value exist for opetion element or not, if value exist then map that else map the null (Empty) value. So the complex element will get generated even if there is no value for optional element.
Hope it will solve your problem.
You can do all this in the mapper. I haven't been into Biztalk for a while and I don't have it near me, but I know there are functiods in the mapper that lets you check for the existence of the fields you need. Depending on the existence of these field, you can specify what the appropriate action for the mapper is.
You force the creation of fields by giving them default values in the target schema. This can also be done using the mapper, via the properties window.
Jose,
You'll want to look at the table looping functoid. Here's a post about it.
http://geekswithblogs.net/Chilberto/archive/2008/04/16/121274.aspx
Using this functoid with the table extraction should give you your solution. Also here's a good series on understadning the mapper.
http://www.bizbert.com/bizbert/2008/02/07/Understanding+The+BizTalk+Mapper+Part+1+Introduction.aspx
-Bryan