Get data from xml response in Jmeter - soap

Hi Everyone!
I would like to get status from this response from Jmeter.How can i create regexp for that?
I just want to get 'vacant' from response
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns5:GetRandomMSISDNListResponse xmlns:ns2="http://www.trump.com/products/common/core" xmlns:ns3="http://www.trump.com/products/common/rr" xmlns:ns4="http://www.yota224.com/vux/domains/common/core" xmlns:ns5="http://www.yota224.com/vux/services/inventory">
<ns2:extension>
<ns2:item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:RequestContextType">
<ns2:correlationId>8f7ce7e1-31ae-40fe-82ba-4d59f634e599</ns2:correlationId>
</ns2:item>
</ns2:extension>
<msisdnList>
<homeRegion>1078</homeRegion>
<msisdn>9992146221</msisdn>
<status>vacant</status>
</msisdnList>
</ns5:GetRandomMSISDNListResponse>
</soap:Body>
</soap:Envelope>

If you targeting to do it via Regular Expressions - the relevant one would be something like:
<status>(\w+)</status>
Here is how it looks in the "RegExp Tester" mode of the View Results Tree listener
Also it might be easier to use XPath Extractor which is designed for working with XML data. In that case the relevant XPath query to get the status will be as simple as:
//status

Related

Parsing XML (SOAP Response) through NetSuite Script

In Netsuite Script I am trying to parse the response from EchoSign Webservice. The response from EchoSign is like this
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<getFormDataResponse xmlns="http://api.echosign">
<getFormDataResult xmlns="http://api.echosign">
<errorCode xmlns="http://dto8.api.echosign">OK</errorCode>
<errorMessage xmlns="http://dto8.api.echosign" xsi:nil="true" />
<formDataCsv xmlns="http://dto8.api.echosign">SOME DATA </formDataCsv>
<success xmlns="http://dto8.api.echosign">true</success>
</getFormDataResult>
</getFormDataResponse>
</soap:Body>
</soap:Envelope>
And my NetSuite code is here
var response = nlapiRequestURL(echoSignUrl, postStr, header);
var xml = nlapiStringToXML(response.getBody());
var resData = nlapiSelectNode(xml, 'soap:Envelope/soap:Body'); // /getFormDataResult/success');
if (resData)
return nlapiSelectValue(resData, 'formDataCsv');
But somehow I always get nothing back from nlapiSelectValue method!!
Nodes without any prefix should be accessed using default prefix nlapi:
for e.g. /soap:Envelope/soap:Body/nlapi:getFormDataResponse
It appears to be an issue with the way the namespacing is handled. Using the XML Tools plugin for Notepad++ and the XML you've provided, the XPATH Current Node Selector can't even find the getFormDataResponse node correctly. It simply fails with "Unknown Exception".
I also tried to manually evaluate the following expressions:
/soap:Envelope/soap:Body (works)
/soap:Envelope/soap:Body/getFormDataResponse (fails)
/soap:Envelope/soap:Body//getFormDataResponse (fails)
/soap:Envelope/soap:Body/*[local-name() = 'getFormDataResponse'] (fails)
/soap:Envelope/soap:Body/descendants::*[local-name() = 'getFormDataResponse'] (fails)
/soap:Envelope/soap:Body/descendants::getFormDataResponse (fails)
If I modify the XML so the EchoSign namespaces are in the Envelope with a prefix, like so:
<soap:Envelope xmlns:echo="http://api.echosign" xmlns:dto8="http://dto8.api.echosign" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<echo:getFormDataResponse>
<echo:getFormDataResult>
<dto8:errorCode>OK</dto8:errorCode>
<dto8:errorMessage xsi:nil="true" />
<dto8:formDataCsv>SOME DATA</dto8:formDataCsv>
<dto8:success>true</dto8:success>
</echo:getFormDataResult>
</echo:getFormDataResponse>
</soap:Body>
</soap:Envelope>
then the path selector can get all the way down to the formDataCsv node correctly. It returns the path: /soap:Envelope/soap:Body/echo:getFormDataResponse/echo:getFormDataResult/dto8:formDataCsv.
Not sure how helpful that is because you're not in control of the XML that EchoSign sends to you, but I'm not sure how to correctly format the XPATH to deal with the namespaces.

Exchange EWS not returning message body for calendar

So i'm trying to fetch all the calendar event from office360.com . I am using ews to get the data. I sent a request of
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Body>
<FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
Traversal="Shallow">
<ItemShape>
<t:BaseShape>AllProperties</t:BaseShape>
<t:BodyType>HTML</t:BodyType>
</ItemShape>
<ParentFolderIds>
<t:DistinguishedFolderId Id="calendar"/>
</ParentFolderIds>
</FindItem>
</soap:Body>
</soap:Envelope>
This soap request xml is not returning me the calendar message body but i get the subject and other data . What am i doing wrong here ? any help is appreciated.
The body needs to be retrieved in a separate call.
http://weblogs.asp.net/psperanza/archive/2008/03/18/getting-calendar-items-using-exchange-web-services.aspx
Or you can load the property first.
http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx
The second is easier but you need to define all properties you want back and if it is a lot, it can be a pain.

Microsoft Dynamics SOAP RetrieveMultiple not returning TotalRecordCount

I'm working with the SOAP API for Microsoft Dynamics CRM 4.0 and for the most part everything is working, but when I'm trying to count the number of total contacts in the database (or for particular queries), it's not respecting the TotalRecordCount=true flag.
Here is the SOAP request that I'm using:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<CrmAuthenticationToken xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
...
</CrmAuthenticationToken>
</soap:Header>
<soap:Body>
<RetrieveMultiple xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<query xmlns:q1="http://schemas.microsoft.com/crm/2006/Query" xsi:type="q1:QueryExpression">
<q1:EntityName>contact</q1:EntityName>
<q1:Distinct>true</q1:Distinct>
<q1:PageInfo>
<q1:ReturnTotalRecordCount>true</q1:ReturnTotalRecordCount>
<q1:PageNumber>1</q1:PageNumber>
<q1:Count>1</q1:Count>
</q1:PageInfo>
</query>
</RetrieveMultiple>
</soap:Body>
</soap:Envelope>
But the response that I'm getting back still contains the following:
TotalRecordCount="-1" TotalRecordCountLimitExceeded="0"
Any idea what I'm doing wrong / missing here?
Do you get any results in your query? E.g. do you recieve the contact records?
I'm pretty sure I've had a problem with this type of approach in the past (using the paging information to get a count).
In any case you will probably have better luck with peforming a FetchXml query with an aggregate function (Im assuming your executing this Soap from JavaScript).
Jamie Miley has a good example of how to do this: http://mileyja.blogspot.co.uk/2011/06/aggregation-count-max-min-etc-and.html
There is a really good designer for FetchXml here: http://www.stunnware.com/

LibXML doesn't find any nodes for my xpath expression

I'm using xpath and LibXML in an iPhone app to find some nodes in an xml document. I'm a noob in xpath so probably i am doing something wrong.
Here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetUserByEmailResponse xmlns="http://tempuri.org/">
<GetUserByEmailResult>
<id>4006</id>
<name>Kudor Gyozo</name>
<email/>
<image/>
<facebookId>0</facebookId>
</GetUserByEmailResult>
</GetUserByEmailResponse>
</soap:Body>
</soap:Envelope>
The xpath expression is //GetUserByEmailResult. No nodes are returned. I expect to get <GetUserByEmailResult> back. If I test the same stuff here it works ok.
UPDATE1: This is what i get back from a .net web service. Is there a way to ignore namespaces in libxml?
I'm not familiar with the iphone library, but you'll probably have to declare the namsepace / prefix somewhere: If you register 'http://tempuri.org/' with 'someprefix', you can search for:
//someprefix:GetUserByEmailResult
A possible workaround is (but not advisable):
//*[local-name()='GetUserByEmailResult']
The GetUserByEmailResult element is in the http://tempuri.org/ namespace so you would need to add that namespace to your XPath search.
You can do so using the xmlXPathRegisterNs function:
xmlXPathRegisterNs(context, BAD_CAST "temp", BAD_CAST "http://tempuri.org/");
Then your XPath would have to be changed to
//temp:GetUserByEmailResult

Problem using NSXMLParser with NOAA data on iPhone

Can anyone help me see why NSXMLParser is not causing these methods
parser:didStartElement:namespaceURI:qualifiedName:attributes:
parser:didEndElement:namespaceURI:qualifiedName:attributes:
to fire for the part of the following data:
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:NDFDgenResponse xmlns:ns1=""><dwmlOut xsi:type="xsd:string"><?xml version="1.0"?>
<dwml version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.nws.noaa.gov/forecasts/xml/DWMLgen/schema/DWML.xsd">
(body excluded)
</dwml>
</dwmlOut></ns1:NDFDgenResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
I'm not an XML expert, but to me, the <dwml></dwml> part looks like just a regular element, to be parsed just like the parts before it.
I do get two parser:parseErrorOccurred: errors, #200 and #201, but they occur during the parsing of the <SOAP-ENV:Body> element, not the <dwml> element, so I'm not sure if they are relevant. Thanks for any help you can give me.
Update: A friend of mine has told me offline of several errors in the data above. I can't understand why NOAA would be sending out malformed XML though -- is there some secret to parsing it?
This is a SOAP web service, you might want to try this: http://code.google.com/p/wsdl2objc/