In this example we get the weather in London from the OpenWeatherMap web service.
Using the Code [top]
- Import the Call a webservice channel from the Builtin: Iguana Webservices repository
- Setup the OpenWeatherMap API
Note: If the key used in the code is still working you can omit this step
- Sign up here to get your own api key
- Paste your key into the code:
- Experiment with the code to find out how it works
- Start the channel
- View the result using the URL specified in the channel source component:
- Adapt the code to your own requirements
- Interactive scripting help is included for this module
This is the github code for the main module:
How it works [top]
This is a simple example of calling a web service and serving up the data. In this case we get the weather in London from the OpenWeatherMap web service.
The process is very straightforward:
- Use net.http.get to call the web service
- Parse the returned data with json.parse
- Serve the result into a web page using net.http.respond
Note: Data is usually returned as XML or JSON and can be parsed using xml.parse or json.parse.