For Rollbase developers working with the SOAP and REST APIs we've published two new documents with code examples showing each API in action. See: Documentation & Tutorials
REST Examples in PHP
Download: rollbase_REST_examples.pdf
The REST API Examples document contains examples of using each method of the Rollbase REST API in PHP. Because some Rollbase API methods require POST requests we use curl. For example the following is a PHP method that can be used to make REST requests using curl:
function restCall($request, $method, $pbody="") {
//Initialize a curl session
$session = curl_init($request);
/* You then set any curl options that you might need. curl
options are listed at
http://us2.php.net/manual/en/function.curl-setopt.php. In this
case, we tell curl that we don't want the HTTP headers returned,
but we do want the request data returned: */
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
if($method == 'POST') {//For post method notify curl
// Tell curl to use HTTP POST
curl_setopt ($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, $pbody);
}
//send request
$response = curl_exec($session);
//close session
curl_close($session);
//this is the response(xml)
return $response;
}
Now we can invoke any Rollbase REST API method easily in PHP. For example, login is the first REST call that should be made to Rollbase in order to establish an API session and retrieve a session ID. To login to a Rollbase account with username TestUser and password mypass our PHP code might look like:
$uname = ‘TestUser’;
$pword = ‘mypass’;
$request =
'https://www.rollbase.com/rest/api/login?loginName='.$uname.'&password='.$pword;
$response= restCall($request, "GET");
Here we are using the above restCall function to make the request. The XML response can now be processed to obtain the session ID. See Rollbase REST API Examples for more...
SOAP Examples in Java
Download: rollbase_SOAP_examples.pdf
The SOAP API Examples document contains examples of using each method of the Rollbase SOAP API in PHP. In addition it also contains an introduction to using the SOAP API with Java using Eclipse WTP (Web Tools Platform) as well as Microsoft Excel.
Eclipse WTP can create appropriate Java stubs by reading and parsing the Rollbase WSDL file available at http://www.rollbase.com/webapi/wsdl/rollbase.wsdl. These stubs can then be used to integrate any of your Java applications with Rollbase.
In our example we use Eclipse WTP to dynamically generate all of the Java classes necessary to develop a client application using the SOAP API:
SOAP Examples in Excel
As with other Microsoft Office applications, Excel provides the ability to use SOAP-based web services. Therefore it is possible to use the Rollbase SOAP API through an Excel spreadsheet and integrate it with your Rollbase account.
Calling a web service in Excel is similar to calling a built-in Excel function, in that you supply information (as arguments) and retrieve a result to display in a particular cell.
Following a few easy steps Excel allows you to point to a WSDL from which it can automatically generate Visual Basic code corresponding to each method defined in the API:
Once this is done, you can then use these methods in your own custom Excel functions. Creating custom functions in Excel is a straightforward exercise using Visual Basic. For example, to call the login method we might create the following function:
Function rb_login(uname As String, pass As String)
Dim clientObj As New clsws_IWebServicesService
Dim session_id As String
rb_login = clientObj.wsm_login(uname, pass
End Function
See Rollbase SOAP API Examples for more...


Comments