Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10116

Re: Using function WebServiceUtilities.ExecuteRESTService()

$
0
0

Hi Sunil,

 

User parameters are typically added to a service URL with a ‘?’(see example below). You can pass multiple user parameters to the reuse function in ABSL and it will append them to the URL. If in your example ‘issue’ is static I would try to use the URL without URL paramters in the .wsid file (xxx.xxx.xxx.xx:port/rest/api/2/issue). The check connection function in the communication arrangement may be misleading as it depends on the used service if it supports this check.

 

Here is an example of a very simple REST service I recently tested. The GeoNames placename lookup with postalcode (JSON) service retrieves the city name for a country and a postal code. This may for example be used during address maintenance to default the city based on country and postal code. To use the service a user registration is required. This service does neither require a resource nor a body.

 

Webservice Type : REST /JSON
Url : api.geonames.org/postalCodeLookupJSON?
Parameters : postalcode,country ,maxRows (default = 20),callback, charset (default = UTF-8)
Result : returns a list of places for the given postalcode in JSON format, sorted by postalcode,placename
Example http://api.geonames.org/postalCodeLookupJSON postalcode=6600&country=AT&username=demo

Description: http://www.geonames.org/export/web-services.html

 

URL entered in the .wsid file: api.geonames.org/postalCodeLookupJSON

 

Script implementation

 

importABSL;

 

//Communication details

 

varScenarioName = "GetCity";

varServiceName = "GetCityByPostalCode";

varHttpMethod = "GET";

varHttpResource = "";                            // not required

varContentType = "";                             // not required

varBody = "";                                    // not required

varHeaderParameter : collectionofNameAndValue// not required

 

 

// Set 3 URL Parameter

varURLParameter    : collectionof NameAndValue;

varURLParameterEntry : NameAndValue;

 

URLParameterEntry.Name  = "country";

URLParameterEntry.Value = this.CountryCode;

URLParameter.Add(URLParameterEntry);

 

URLParameterEntry.Name  = "postalcode";

URLParameterEntry.Value = this.PostalCode;

URLParameter.Add(URLParameterEntry);

 

URLParameterEntry.Name  = "username";

URLParameterEntry.Value = < Add your GeoNames user name>;

URLParameter.Add(URLParameterEntry);

 

// execute web service call

 

varws_result = WebServiceUtilities.ExecuteRESTService(ScenarioName, ServiceName,HttpMethod, HttpResource,
URLParameter, HeaderParameter,ContentType, Body);

 

// Parse result

...

 

 

Kind Regards,

Thomas


Viewing all articles
Browse latest Browse all 10116

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>