18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

webservices testing using REST API

Hi below is the snippet from sahi pro 5.x
var $request = new RESTRequest();
$request.setURL("http://www.webservicex.net/geoipservice.asmx/GetGeoIP";);
$request.addToQueryString("IPAddress", "72.14.228.129");
var $response = $request.submit("get");
var $responseBody = $response.getBodyAsString();

// The response is in the form of an xml, so we will parse the xml.
// Alternatively, this can be JSON in which case, we would need to eval the JSON to get the output object attributes.
$data = $responseBody.replace(/<\?xml[^>]*\?>/, "").replace(/(\r\n|\n|\r)/gm,"");
default xml namespace = "http://www.webservicex.net/";
var $x = new XML($data);
var $CountryCode= $x..CountryCode[0].toString();
_alert($CountryCode);

i assume this would work in sahi 7.5 ?
i see that while invoking the webservices we need to pass the IP address 72.14.228.129 ? is that the server IP where the webservices is running
Thx
K.Thulsi

Comments

Sign In or Register to comment.