WsGetValues
The WsGetValues action returns one or more values from a web service.
Syntax
bool WsGetValues (string url, string nsprefix, string nsuri, string source, string target, string format, string savefile)
Parameters
- url
- Required: the URL of the web service.
- nsprefix
- Optional: the prefix of the Namespace if you are using tags to obtain results.
- nsuri
- Optional: the Namespace URI. If a namespace has already been set, you do not need to set the URI.
- source
- Optional: the xpath or tag to obtain the value. The xpath/tag and target are set separately.
- target
- Optional: the target DCO. You can set the xpath/tag and target separately, and if no path is set then the entire result set is saved to the target.
- format
- Optional: the return format type. The default is XML.
- savefile
- Optional: save the response results to this file for reference.
Returns:
True, if the action succeeds. Otherwise, False.Level
All levels.Details
The value for the URL should include the end point. This is the only required value if the parameters and target values are set before calling the action. Smart parameters are supported.Example
Example 1 uses xpath with a namespace to obtain information from the web service:WsGetvalues("http://api.worldbank.org/countries?format=xml", "wb", "http://www.worldbank.org", "//wb:countries/wb:country[5]/wb:name", "@B.Country", "", "C:\myfolder\myfile.xml")
Example 2 uses tag value to obtain the information:
WsGetvalues("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=GBP", "", "", "double", "@B.ConversionRate", "", "")
Example 3 shows the syntax for JSON:
WsSetParameter("symbols", "USD", true)
WsSetParameter("symbols", "GBP", true)
WsGetvalues("http://api.fixer.io/latest?", "", "", "", "", "JSON", "@PILOT(BATCHDIR)+/+rates +.json")