Implementing a Skip Token OData Query Option ($skiptoken) for SOAP data using Integration Gateway
Introduction: What is $skiptoken?
When working with OData services, a developer might use the $top and $skip commands so that the client application can control paging.
However, some client applications might be coded inefficiently or even with malicious intent, so you might like to enforce Server Side Paging supported by the OData protocol. This means that the server does not return all results at once, but only a subset or “page” of all results.
If you choose to implement this, the client usually needs to know how many results there as a whole. To find this out, you can append the $inlinecount option to your query, like this:
The results will include a total count ‘inline’, and a url generated to get the next page of results.
The generated url includes a $skiptoken, that is the equivalent of a cursor or bookmark, that instructs the server where to resume:
Note: This feature is available for SP07 onwards.
In order to support the scenario above, $top and $skip are most likely used along with $skiptoken. Hence the operation should handle $top, $skip and $skiptoken OData operation together.
- Create an OData Service Implementation Project
- Create an OData Model that includes a “Products” entity set for getProduct operation, which can have properties ProductID,ProductName, ProductDescription,,SupplierId,isDeleted
3. Right click on odatasrv file on the lefthand side of your Service Implementation Project and choose “Select data source”.
4. Select your entity set and choose the query CRUD operation. Select the data source SOAP Service.
5.Specify your required wsdl file and choose the required query operation from the list of soap operations and click on finish
8. The skip token value has to be fetched from the OData request URI and this value must be sent to the web service operation as an input parameter. A hashmap must be created in the processRequestData function with the input parameters (skipTokenID, top, skip) that will be passed in the URI. These parameters must then be set to message body as follows:
var uriInfo = message.getHeaders().get(ODataExchangeHeaderProperty.UriInfo.toString());
var top = “”;
var skip = “”;
var productId = “”;
if (uriInfo.getTop() !=null)
top = uriInfo.getTop();
if (uriInfo.getSkip()!= null)
skip = uriInfo.getSkip();
if (uriInfo.getSkipToken() != null)
productId = uriInfo.getSkipToken();
var parentMap = new LinkedHashMap();
// Add the Top and Skip productId and skipToken values to map
log.logErrors(LogMessage.TechnicalError, “Values set correctly”);
// Set the message body back
9. In our sample implementation, the OData request would look as follows:
The resulting outgoing SOAP request body should then look as follows:
In this example, the $skipToken value equals 101 which is the ProductID of the last product. $skipToken value = 2 means, you will get only 2 entries at a time. This returns the next two entries. In this operation, moreEntries gives the information, if there are some more entries still there or not.
<ProductDesc>5L Olive Oil Can</ProductDesc>
10. Once the web service response is returned, the response includes the entries and information whether there exist some more entries. These entries have to be added in the result set in processResponseData function. Also, we need to set the next the $skipToken value using the
11. Right click on Query and select Define Response Mapping
12. Do the response mappings from your entity set to your WSDL file as required.
13. Right Click on your Service Implementation Project and select “Generate and Deploy Integration Content”. This will deploy the bundle to your
The support of skipToken and its implementation depends on web service, so you will have to adapt this example for your specific service.