How To : Accessing a REST Web Service

Page Status: Beta

Back to Concepts and HOW TOs

Contents

[edit] Description

This document describes how to access a REST web service using Bungee Builder. 

[edit] Prerequisites

Understanding REST

[edit] Procedure

To access a REST web service:
  1. Build your URL: Create a means of entering information so that a URL is created. For example, in the case of Google Maps, the user types the address they want mapped into a text box.
  2. Pass the URL to the Web service: Use the HTTP class to make a Get request (use the returnGet function with two arguments: the first argument is the URL and the second is the response that is returned).
  3. Parse the response: An XML string is returned by returnGet. Use XMLDocObject to parse the string.

Notes 

  • XMLDocObject and HTTP are classes that already exist under Runtime (in typelib Utility). Note: There are three additional XML classes available: XMLAttribute , XMLDataObject, and XMLElement).
  • For parsing the XML string, use the function of XMLDocObject. It creates a DOM tree from the XML string, and produces the root object. From then on, you’re accessing the root (the string is reflected now in an object structure that’s been parsed in by XMLDocObject).
  • Use the functions on XMLElement to fully traverse the tree. You use getChild or getAttribute to actually get the objects you’re looking for in the call (you could also use getChildByAttrName to get a child that matches both the childName argument and the attrName argument.
  • The root (from the kml tag in the XML file) has a list of children, and may have attributes (those are the two datasets besides content and name).
  • In XML you have either children or content, not both. So a child can either have more children or it can have content. As you traverse the tree, you either traverse through a child list or you grab the content.

[edit] Error Handling

 

[edit] Examples

 

[edit] Next Steps

Adding a Class to a Project
Adding a Function to a Class
Adding a Field to a Class
Adding a Form to a Class

[edit] Tags

 

 

 

    Copyright © 2005 - 2007 Bungee Labs. All rights reserved.