Posts

Generic REST Service Call - Using Java and Wink API

Below is a Java REST service example for Generic Service call using Wink API. Override methods according to the requirement. /************************************************************************* * REST Service Example * *************************************************************************/ import javax.ws.rs.core.MediaType; import org.apache.wink.client.ClientConfig; import org.apache.wink.client.ClientResponse; import org.apache.wink.client.Resource; import org.apache.wink.client.RestClient; import org.apache.wink.client.handlers.BasicAuthSecurityHandler; public class Test {     public static void main(String[] args) {                 try {             //1. Execute Get Service.             Resource restClientResource =  getRestClientResource("username", "password", "serviceUrl"); ...

Generic REST Service Call - Using Java Script and DOJO

Generic Java Script functions to invoke REST service using DOJO. /*************************************************************************** *  JavaScript-Code-Snippet ***************************************************************************/ /**  * Invokes REST service call for GET method.  * @param arg_url  * @param arg_sync  * @param arg_loadMethod, which handles the response.  * @param arg_handleAs, which hanles the reponse type. For ex. json/text etc.  */ function executeGet(arg_url, arg_sync, arg_loadMethod, arg_handleAs){ var resultData = null; var responseData = null; //validate parameters. console.log("Ajax Service Call for Get Method."); resultData = dojo.xhrGet({ url : arg_url, //postData : valueStr, handleAs : arg_handleAs, timeout : 5000, load: arg_loadMethod, sync : arg_sync, error : fnToHandleGetServiceErrorResponse, preventCache: true }); ...