Skip to content

Setup and Initialization

Instantiate a Provider

// Instantiate new provider instance
OnlineODataProvider provider = new OnlineODataProvider("\"v4Service\"", "http://services.odata.org/V4/(S(readwrite))/OData/OData.svc/");
val provider = OnlineODataProvider("\"v4Service\"", "http://services.odata.org/V4/(S(readwrite))/OData/OData.svc/")

Instantiate a Service Instance

The service instance is used to invoke back-end operations.

DemoService demoService = new DemoService(provider);
// Get provider back from service reference
provider = (OnlineODataProvider) demoService.getProvider();
val demoService = DemoService(provider)
// Get provider back from service reference
provider = demoService.provider

Service Configuration Options

Configuration APIs are provided to set various options for interaction with the OData service. Usage of these APIs is optional.

// Disable data service version check
provider.getServiceOptions().setCheckVersion(false);

// Configuration
//
// Set trace options
provider.setTraceRequests(true);
provider.setTraceWithData(true);
provider.setPrettyTracing(true);

// Service Options
//
// Set ATOM as the data interchange format of
provider.getServiceOptions().setDataFormat(DataFormat.ATOM);
// OR, set JSON as the data interchange format (default)
provider.getServiceOptions().setDataFormat(DataFormat.JSON);

// If service does not support batch, turn off batch requests
provider.getServiceOptions().setSupportsBatch(false);

// Network Options
//
// Allow HTTP verb tunneling over OData batch requests
provider.getNetworkOptions().setAllowTunneling(true);
// Disable compression
provider.getNetworkOptions().setCompressResponses(false);
// Disable streamed downloads
provider.getNetworkOptions().setStreamDownloads(false);
// Disable streamed uploads
provider.getNetworkOptions().setStreamUploads(false);

// Ping service to check connection
demoService.pingServer();
// Disable data service version check
provider.serviceOptions.checkVersion = false

// Configuration
//
// Set trace options
provider.traceRequests = true
provider.traceWithData = true
provider.prettyTracing = true

// Service Options
//
// Set ATOM as the data interchange format of
provider.serviceOptions.dataFormat = DataFormat.ATOM
// OR, set JSON as the data interchange format (default)
provider.serviceOptions.dataFormat = DataFormat.JSON

// If service does not support batch, turn off batch requests
provider.serviceOptions.supportsBatch = false

// Network Options
//
// Allow HTTP verb tunneling over OData batch requests
provider.networkOptions.allowTunneling = true
// Disable compression
provider.networkOptions.compressResponses = false
// Disable streamed downloads
provider.networkOptions.streamDownloads = false
// Disable streamed uploads
provider.networkOptions.streamUploads = false

// Ping service to check connection
demoService.pingServer()

Last update: August 12, 2020