REST API:BaseUtil

From AgileApps Support Wiki
Revision as of 01:00, 9 September 2010 by imported>Aeric
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The BaseUtil class contains methods that are useful when generating requests and processing responses in a subclass of BaseClient.

Thumbsup.gif

Tip: The REST_samples.zip file contains this utility class, BaseClient (which uses), and extensions to BaseClient that demonstrate REST operations.

prettyPrint(InputStream xml_in)
Displays nicely-formatted, indented XML.
xpath_result(String xpath_expr, String xml)
Given an XPath expression and an XML string, returns a string with the corresponding value from the XML. So for <platform><message><status>200</status>..., the XPath expression "/platform/message/status" returns "200".
mediaType(String filename)
Examines a filename's extension and returns a string with the appropriate MIME type for that kind of a file, so it can be inserted into a header. For example, if the extension is ".txt", it returns "text/plain".