Mobile Development Examples and Videos
Below are resources for working with the ADS Web Platform in different environments.
Tutorial Screencasts
There are many screencasts to help you get started working with the Advantage Web Platform
- Advantage Web Platform Overview - An overview to the Advantage Web Platform
- Advantage Web Platform Configuration - Learn to configure the Web Platform and retrieve data using an HTML interface
- Advantage OData Web Application JavaScript Client - Introduction to the basics of the web platform with the Javascript Client complete with code examples.
- Mobile Device Support - Learn how the Web Platform supports all types of mobile devices including iPhone and Android
iPhone Getting Started
Videos
| iPhone oData Client Part 1 Getting Started with ADS |
iPhone oData Client Part 2 Background Thread Creation, UI Enhancements |
iPhone oData Client Part 3 Insert, Update and Delete |
Android Getting Started
Sample Application
A sample Android application using the Advantage Web Platform can be found here.
Code Samples
Web Browser
The easiest way to test the service is to simply enter a URI into your browser. For example, entering the following URI into your browser after installing the server: https://myserver:6282/adsweb/v1/test_db/tables/orders would return:
.NET
Consumption from the .NET framework is accomplished using the built in WebClient class in combination with the JSON.NET library for JSON serialization and de-serialization:
WebClient w = new WebClient();
w.Headers.Add( "Authorization", "Basic " +
Convert.ToBase64String( Encoding.ASCII.GetBytes( "adssys:" ) ) );
w.Encoding = Encoding.UTF8;
string result = w.DownloadString(
"https://myserver:6282/adsweb/v1/test_db/tables/orders" );
sr = new StringReader( result );
olist = (oDataResults<Orders>)serializer.Deserialize( new JsonTextReader( sr ),
typeof( oDataResults<Orders> ) );
// Results are now ready to use in an object list
if ( olist.d.results.Count > 0 )
MessageBox.Show( string.Format( "First order ID is {0}",
olist.d.results[0].id.ToString() ) );
iPhone/iPad (Objective-C)
Consumption in Objective-C is accomplished using the URLWithString constructor and the TouchJSON library :
NSString *jsonString = [NSString stringWithContentsOfURL:
[NSURL URLWithString: @"https://myserver:6268/adsweb/v1/test_db/tables/orders"]
encoding: NSUTF8StringEncoding error:&error];
// deserialize
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding];
NSDictionary *dictionary =
[[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
// save reference to the rows
_rows = [[NSMutableArray alloc] initWithArray:[dictionary objectForKey:@"d"]];
[_rows retain];
Android (Java)
Consumption in Java is accomplished using the WebClient class and the Gson library:
WebClient ordersClient =
new WebClient( "https://myserver:6282/adsweb/v1/test_db/tables/orders" );
String jsonOrders = ordersClient.GetData( "total>50000" )
Gson gson = new Gson();
OrdersListWrapper ordersList = gson.fromJson( jsonOrders, OrdersListWrapper.class );
// The deserialized Results are now contained in the "d" object array.
if ( ordersList.d.Count > 0 ) {
TextView tvResults = (TextView)mainView.findViewById( R.id.txtResults );
tvResults.setText( "The First Order ID is " +
(new Integer( ordersList.d[0].id ).toString() ));
}
JavaScript
The following example consumes the API using Javascript in a browser, and uses the JQuery framework to quickly manipulate the JSON data and present a table:
<script language="javascript">
$.getJSON('https://myserver:6282/adsweb/v1/test_db/tables/orders',
function(data, status){
$.each( data.d, function(i, item) {
$('#res').append( '<li>Order ' + item.OrderNo + ' : $' + item.AmountPaid + '</li>' );
} );
});
</script>
<ul>
<div id=res>
</div>
</ul>
PHP
The following example consumes the API using PHP, and uses the CURL extension and built in json_decode function:
$session =
curl_init("https://localhost:6282/adsweb/pupdir/v1/query/select%20*%20from%20test1");
// configure CURL to trust our server with self-signed cert
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
// set db password
curl_setopt($session, CURLOPT_USERPWD, "adssys:");
// setup curl_exec to return the data instead of printing it
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// set headers
curl_setopt($session, CURLOPT_HTTPHEADER,
array ( "Accept: application/json; charset=utf-8" ) );
// get the data
$response = curl_exec($session);
curl_close($session);
// decode the json into an object
if ( ! $dataset = json_decode( $response ) )
trigger_error( json_last_error() );
// spit out a simple table (normally would use a view, but not in small example)
print( "<table><tr><hr><th>Lastname</th><th>Firstname</th></tr>" );
foreach ( $dataset->d->results as $row )
print( "<tr><td>$row->LASTNAME</td><td>$row->FIRSTNAME</td></tr>" );
print( "</table>" );

Back to Top