Skip to content

ODataOnlineCore Getting Started guide

Library for consuming OData version 4.0 and OData version 2.0 services.

Step 1: Create a new Android project in Android Studio

Step 2: Setup project dependencies

I.) The required dependencies * SupportabilityFacade.aar * ClientLog.aar * HttpConversation.aar * HttpConvAuthFlows.aar * ODataOnlineCore.aar

II.) Copy required dependencies Copy the required dependencies from SMP SDK installer to the libs folder(Application/app/libs).

III.) Add dependencies to the internal build.gradle (app/build.gradle) The dependencies have to be added to the project in the build.gradle file. The new installer contains Android Archive Libraries (aar files), you have to add these libraries to the dependencies section: compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')

IV.) Add flatDir to repositories The flatDir have to be added to repositories without this the application will not find the required dependencies. You have to add the repositories to the internal build.gradle(app/build.gradle):

repositories {
   flatDir {
        dirs 'libs'

Step 3: Create proxy classes for your OData service

  • Have Java JDK or JRE installed on your machine and global variable JAVA_HOME set
  • Choose an OData service you want to use and download the metadata, giving it a name that can identify this service, but try to make it short. Recommended directory: ODataOnlineCore proxy generator location/bin/.

  • For proxy class generation there is two different methods.

On Mac machines you can use: metadata.xml -android

Or if you want more control on package and class names you must run two script:
xs-proxy metadata.xml proxy_output_file.xs -package package_name -service YourService
xsc proxy_output_file.xs -java -smp3 -android
The first parameter of xs-proxy script is your newly downloaded metadata

Step 4: Assemble your project

Open your Android Studio project what you have created and add the generated sources(by your script) to the project. Navigate to the location where your ODataOnlineCore proxy generator is located/genfiles/android and copy the sources to the Android Project/app/src/main/java Add the genrated source files to src/main/java. Now your project should compile.

Step 5: Write some code

//add android context for ODataOnlineCore sdkLogger

// Create HttpConversationManager and configure it according no authentication method.
HttpConversationManager conversationManager =new HttpConversationManager( getContext( ) );
//Create online provider
OnlineODataProvider provider = new OnlineODataProvider(SERVICE_NAME, SERVICE_URL);
SDKHttpHandler sdkHttpHandler = new SDKHttpHandler(getContext(), conversationManager);
// Create service
//YourService is the same service that you used during the proxy generation
YourService yourService = new YourService(provider);

//After this point your service can be used
//Proxy generation generate these classes for each collection in metadata
YourCollection collection = yourService.getYourCollection();

// Batch requests can be created like this:
 public void processBatchExample() {
     NorthwindService service = this.getService();
     Supplier supplier1 = service.getSupplier(new DataQuery().top(1));
     Supplier supplier2 = supplier1.copy();
     Supplier supplier3 = supplier1.copy();
     Supplier supplier4 = supplier1.copy();
     supplier2.setCompanyName("Alpha Inc.");
     supplier3.setCompanyName("Beta Inc.");
     supplier3.setCompanyName("Gamma Inc.");
     Product product1 = service.getProduct(new DataQuery().top(1));
     Product product2 = product1.copy();
     product2.setProductName("Delta Cake");
     RequestBatch batch = new RequestBatch();
     ChangeSet changes = new ChangeSet();
     changes.createLink(product2, Product.supplier, supplier4);
     DataQuery query = new DataQuery()
     List<Supplier> suppliers = Supplier.list(batch.getQueryResult(query)

You can also find examples within the ODataOnlineCore proxy class generator bundle under the examples directory.