how to use data extraction API for java applications?

you can absolutely use Java to access the data.  Many people already have in creating Java apps, web apps, Android Java apps, and Blackberry Java ME apps.

We created our Data Extraction API in such a way that it is _code free_!  You don't need any code to get data using our REST requests.  In fact, try it out and log in and create a REST url from our http://generator.webtrends.com and then paste the REST URL into your browser address bar and the data will simply return (after you authenticate of course).

But I can give you some helpful pointers for getting your Java app running with our data embedded in it.

The process is simple.

Short summary:

All you need is a java library for making an https connection.
Pass your webtrends account name along with your username in the authentication process with a backslash seperator.
Create your REST request in generator.webtrends.com and choose a format you prefer.
Add a parser library to your java code for the format you chose.

Step by step pointers:

1) For libraries, to make an Extraction request, all you need is any method of making an https request (there are lots of http helper libraries out there) with authentication.  In order to make this as easy to embed in applications as possible, we use http authentication.  Here is a link to apache commons libraries:  http://commons.apache.org/

2) when you pass your username and password in the https request you need to follow this format:

     Username should look like:    webtrendsAccountName\userName     (i.e. the username should have your webt account, backslash, username)

     Password should look like:   password    (send your password as normal of course)

3) practice with a simple Webtrends REST request first.  Create one in generator (http://generator.webtrends.com) from a basic report for "this month" and copy and paste the URL it generates for you into your test code.

4) once you send the https request Webtrends will respond with all the data.  No extra code is needed of any kind.  In fact, if you were to paste that REST request into your browser, the data would simply show in your browser window.

     Do you want it in XML, JSON or HTML format?

     Many developers find it easiest to recieve data in XML because there are so many XML parsers out there.  See my link above to apache commons.

I suggest you use our XML format made friendly for developers and change your rest request to show format=xml2

That "xml2" is not a typo.  We have two xml formats to use and xml2 is the easiest to automate parsing for.

5) get yourself a java parser for the format you chose in step 4.  Apache commons has one for both XML and JSON.  If you want to pursue JSON further (json is more compact, faster and efficient but not as easy to develop for) go to http://json.org/index.html and scroll down and you'll find a dozen or more json parsers for every platform.  If you are using Java to develop for Android, I recommend "gson".

你可能感兴趣的:(java,json,android,REST,BlackBerry)