Apigee has an extensive Force.com REST interface to interact with Salesforce. Follow this tutorial to create an app in apigee, create a remote connection in Salesforce, add a user to the app to get your smart-key.
Complete the tutorial below to get the information needed to run this class:
http://developer.apigee.com/salesforce_tutorial.html
You will need the following to run this class:
1. Smart-key
2. Application Name
import com.apigee.sdk.oauth.api.exception.RestCallException;
import com.apigee.sdk.oauth.api.rest.RestCallResult;
import com.apigee.sdk.oauth.api.rest.RestCall;
import com.apigee.sdk.oauth.impl.model.Request;
public class ForceApigee {
//Configure your SMARTKEY and APPNAME
final static String SMARTKEY = "YOURSMARTKEY";
final static String APPNAME = "YOURAPPLICATIONNAME";
final static String PROVIDER = "salesforce";
final static String VERSIONENDPOINT = "/services/data";
final static String RESOURCESENDPOINT = "/services/data/v27.0";
final static String SOBJECTENDPOINT = "/services/data/v27.0/sobjects";
final static String SOBJECTBASICENDPOINT = "/services/data/v24.0/sobjects/Account";
final static String SOBJECTDESCRIBEENDPOINT = "/services/data/v27.0/sobjects/Account/describe";
final static String SOQLQUERYENDPOINT = "/services/data/v24.0/query?q=SELECT name from Account";
final static String SOQLSEARCHENDPOINT = "/services/data/v24.0/search?q=FIND {test} IN ALL FIELDS";
public static String callToSalesforce(Request.HttpVerb verb, String Endpoint)
{
try
{
RestCallResult result = new RestCall(verb, Endpoint)
.withSmartKey(SMARTKEY)
.toProvider(PROVIDER)
.usingApp(APPNAME)
.invoke();
return result.getResponsePayload().toString();
} catch (RestCallException e) {
return e.getMessage();
}
}
public static void main(String[] args)
{
System.out.println("***VERSIONENDPOINT****: \n" + callToSalesforce(Request.HttpVerb.GET, VERSIONENDPOINT));
System.out.println("***RESOURCESENDPOINT***: \n" + callToSalesforce(Request.HttpVerb.GET, RESOURCESENDPOINT));
System.out.println("***SOBJECTENDPOINT***: \n" + callToSalesforce(Request.HttpVerb.GET, SOBJECTENDPOINT));
System.out.println("***SOBJECTBASICENDPOINT***: \n" + callToSalesforce(Request.HttpVerb.GET, SOBJECTBASICENDPOINT));
System.out.println("***SOBJECTDESCRIBEENDPOINT***: \n" + callToSalesforce(Request.HttpVerb.GET, SOBJECTDESCRIBEENDPOINT));
System.out.println("***SOQLQUERYENDPOINT***: \n" + callToSalesforce(Request.HttpVerb.GET, SOQLQUERYENDPOINT));
System.out.println("***SOQLSEARCHENDPOINT***: \n" + callToSalesforce(Request.HttpVerb.GET, SOQLSEARCHENDPOINT));
}
}