OData v4 Features
Supported Operators
|
Authentication Options |
Description |
|
|
Comparison Operators: |
|
|
|
eq |
Equal |
companyname eq ‘Able Computing’ |
|
ne |
Not Equal |
companyname ne ‘Able Computing” |
|
gt |
Greater than |
price gt 20 |
|
ge |
Greater than or equal |
price ge 10 |
|
lt |
Less than |
price lt 20 |
|
le |
Less than or equal |
price le 100 |
|
Logical Operators |
|
|
|
and |
Logical and |
Price le 200 and Price gt 3.5 |
|
or |
Logical or |
Price le 3.5 or Price gt 200 |
|
not |
Logical negation |
not endswith(Description,'milk') |
|
Operator |
Description |
Example |
|
Arithmatic Operators |
|
|
|
add |
Addition |
Price add 5 gt 10 |
|
sub |
Subtraction |
Price sub 5 gt 10 |
|
mul |
Multiplication |
Price mul 2 gt 2000 |
|
div |
Division |
Price div 2 gt 4 |
|
mod |
Modulo |
Price mod 2 eq 0 |
|
Grouping Operators |
|
|
|
( ) |
Precedence grouping |
(Price sub 5) gt 10 |
Supported Functions
|
Function |
Example |
|
String Functions |
|
|
contains |
contains(CompanyName,'freds') |
|
endswith |
endswith(CompanyName,'Futterkiste') |
|
startswith |
startswith(CompanyName,'Alfr') |
|
length |
length(CompanyName) eq 19 |
|
indexof |
indexof(CompanyName,'lfreds') eq 1 |
|
substring |
substring(CompanyName,1) eq 'lfreds Futterkiste' |
|
tolower |
tolower(CompanyName) eq 'alfreds futterkiste' |
|
toupper |
toupper(CompanyName) eq 'ALFREDS FUTTERKISTE' |
|
trim |
trim(CompanyName) eq 'Alfreds Futterkiste' |
|
concat |
concat(concat(City,', '), Country) eq 'Berlin, Germany' |
|
Date Functions |
|
|
year |
year(BirthDate) eq 0 |
|
month |
month(BirthDate) eq 12 |
|
day |
day(StartTime) eq 8 |
|
hour |
hour(StartTime) eq 1 |
|
minute |
minute(StartTime) eq 0 |
|
second |
second(StartTime) eq 0 |
|
fractionalseconds |
second(StartTime) eq 0 |
|
date |
date(StartTime) ne date(EndTime) |
|
time |
time(StartTime) le StartOfDay |
|
totaloffsetminutes |
totaloffsetminutes(StartTime) eq 60 |
|
now |
StartTime ge now() |
|
mindatetime |
StartTime eq mindatetime() |
|
maxdatetime |
EndTime eq maxdatetime() |
|
Math Functions |
|
|
round |
round(Freight) eq 32 |
|
floor |
floor(Freight) eq 32 |
|
ceiling |
ceiling(Freight) eq 33 |
|
Type Functions |
|
|
cast |
cast(ShipCountry,Edm.String) |
Support for Published Resources
OData v4 supports
| • | All published database and webservice resources. |
| • | Published views without a primary key defined. |
| • | Procedures with multiple input and output cursors. |
| • | Supports navigation links of tables/views with defined relationships. |
Examples
Call procedure which has parameters.
http://dvbu-vdi-002:9400/odata4/webservices/ds/LookupProduct(desiredProduct=1
Call procedure which has input cursor
<m:value xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xmlns:d="http://docs.oasis-open.org/odata/ns/data" m:type="#Edm.LookupProductReturnType" m:context="http://dvbu-vdi- 002:9400/odata4/webservices/ws$metadata">
<m:parameters>
<d:result m:type="#Collection(Edm.result)">
<m:element>
<d:ProductName>Maxtific 40GB ATA133 7200</d:ProductName>
<d:ProductID m:type="Int32">1</d:ProductID>
<d:ProductDescription>Maxtific Storage 40 GB</d:ProductDescription>
</m:element>
</d:result>
</m:parameters>
</m:value>
Support For Pagination
OData v4 supports Server side pagination.
By default the page size is set to 10,000 rows. You can change this value by tuning the Server Configuration in the Studio -> Administration -> Configuration -> Server -> Web Services Interface -> OData -> ODATA Max Page Size”. Note that the Max Page Size cannot exceed 100,000 rows.
This setting determines the maximum number of rows to send to the client. The client can override, but not exceed this setting. The client can set it via HTTP headers "Prefer: odata.maxpagesize=XXX". Partial datasets returned to the client will contain an atom:link with a "next" relation whose "href" value is the URI of the next partial dataset.
Additionally, you can tune the setting ODATA Skiptoken to enable server driven paging via the odata system query option $skiptoken. If this option is set to False, paging will use the odata system query option $skip instead, which may cause performance issues.
Examples
1. In the example below, the client requests only 8 rows per response:
curl -u admin:admin "http://localhost:9400/odata4/webservices/soap_test/view_test/CompositeView?\$format=xml" -H "Prefer: odata.maxpagesize=8"
2. If the server has pagination enabled, responses will have an extra element that contains the url attribute skiptoken
<a:link rel="next" href="http://localhost:9400/odata4/webservices/soap_test/view_test/CompositeView?%24format=xml&%24skiptoken=54ed17bcx39b1x4648x8e3axe146c401d935"/></a:feed>
To iterate the result set, you need the skiptoken supplied in the previous response. The response will generate a new skiptoken if there is more result set to display.
Timeout
You can control the request timeouts for the OData paginated requests, by tuning the server property OData Timeout. You can access it by choosing Administration -> Configuration -> Server -> Webservices -> OData -> Odata timeout. The value specified is in seconds for the paginated requests. Use 0 for unlimited. You need to also adjust the session purge period (Administration -> Configuration -> Server -> Runtime Processing Information -> Sessions) to fine tune ODATA timeouts.
Supported Query options
The following query options are supported:
| • | $apply |
| • | $count |
| • | $expand |
| • | $filter |
| • | $levels |
| • | $orderby |
| • | $search |
| • | $select |
| • | $skip |
| • | $top |