org.ala.client.util
Class RestfulClient

java.lang.Object
  extended by org.ala.client.util.RestfulClient

public class RestfulClient
extends java.lang.Object

Restful Web Service Client.

Author:
MOK011

Field Summary
 int timeout
           
 
Constructor Summary
RestfulClient()
           
RestfulClient(int timeout)
           
 
Method Summary
 java.lang.Object[] restGet(java.lang.String url)
          Makes a GET request to the specified url.
 java.lang.Object[] restGet(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> header)
          Makes a GET request to the specified url.
 java.lang.Object[] restPost(java.lang.String url, java.lang.String jsonRequestBody)
          Makes a POST request to the specified URL and passes the provided JSON Object
 java.lang.Object[] restPost(java.lang.String url, java.lang.String mimeType, java.util.Collection object)
          Makes a POST request to the specified URL and passes the provided JSON Object
 java.lang.Object[] restPost(java.lang.String url, java.lang.String contentType, java.lang.String jsonRequestBody)
          Makes a POST request to the specified URL and passes the provided JSON Object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeout

public int timeout
Constructor Detail

RestfulClient

public RestfulClient()

RestfulClient

public RestfulClient(int timeout)
Method Detail

restPost

public java.lang.Object[] restPost(java.lang.String url,
                                   java.lang.String contentType,
                                   java.lang.String jsonRequestBody)
                            throws org.apache.commons.httpclient.HttpException,
                                   java.io.IOException
Makes a POST request to the specified URL and passes the provided JSON Object

Parameters:
url - URL Endpoint
mimeType - return mimeType
jsonRequestBody - JSON Object to post to URL
Returns:
[0]: status code; [1]: a JSON encoded response
Throws:
java.io.IOException
org.apache.commons.httpclient.HttpException

restPost

public java.lang.Object[] restPost(java.lang.String url,
                                   java.lang.String jsonRequestBody)
                            throws org.apache.commons.httpclient.HttpException,
                                   java.io.IOException
Makes a POST request to the specified URL and passes the provided JSON Object

Parameters:
url - URL Endpoint
jsonRequestBody - JSON Object to post to URL
Returns:
[0]: status code; [1]: a JSON encoded response
Throws:
java.io.IOException
org.apache.commons.httpclient.HttpException

restPost

public java.lang.Object[] restPost(java.lang.String url,
                                   java.lang.String mimeType,
                                   java.util.Collection object)
                            throws org.apache.commons.httpclient.HttpException,
                                   java.io.IOException
Makes a POST request to the specified URL and passes the provided JSON Object

Parameters:
url - URL Endpoint
jsonRequestBody - JSON Object to post to URL
Returns:
[0]: status code; [1]: a JSON encoded response
Throws:
java.io.IOException
org.apache.commons.httpclient.HttpException

restGet

public java.lang.Object[] restGet(java.lang.String url)
                           throws org.apache.commons.httpclient.HttpException,
                                  java.io.IOException
Makes a GET request to the specified url.

Parameters:
url - URL Endpoint with request parameters.
Returns:
[0]: status code; [1]: a JSON encoded response.
Throws:
java.io.IOException
org.apache.commons.httpclient.HttpException

restGet

public java.lang.Object[] restGet(java.lang.String url,
                                  java.util.Map<java.lang.String,java.lang.String> header)
                           throws org.apache.commons.httpclient.HttpException,
                                  java.io.IOException
Makes a GET request to the specified url. if header is null then server will return default data type.

Parameters:
url - URL Endpoint with request parameters.
header - eg: "Accept" "application/json"; "Accept" "text/xml"
Returns:
[0]: status code; [1]: a JSON encoded response.
Throws:
java.io.IOException
org.apache.commons.httpclient.HttpException


Copyright © 2014 ALA. All Rights Reserved.