Skip to content

Setup and Initialization

Instantiate a Provider

1
2
// Instantiate new provider instance
OnlineODataProvider provider = new OnlineODataProvider("\"v4Service\"", "http://services.odata.org/V4/(S(readwrite))/OData/OData.svc/");
1
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 backend operations.

1
2
3
DemoService demoService = new DemoService(provider);
// Get provider back from service reference
provider = (OnlineODataProvider) demoService.getProvider();
1
2
3
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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 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();
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 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()