Skip to Content
Author's profile photo Mohan Kumar Agarwal

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.

Implementing a custom JavaScript to support Server Side Paging for your SOAP data source

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.

Steps in the SAP Mobile Platform Tools

  1. Create an OData Service Implementation Project
  2. 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


6. Right click on Query and select Define Custom Code


7. Select the script type as either JavaScript or Groovy script. In this example we chose to implement the custom code using JavaScript.


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:

processRequestData(message) {



     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

           parentMap.put(“ProductId”, productId);

           parentMap.put(“top”, top);

           parentMap.put(“skip”, “”);

           parentMap.put(“skiptoken”, “2”);

    // Logger

           log.logErrors(LogMessage.TechnicalError, “Values set correctly”);

    // Set the message body back


     return message;


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.


<getProductsResponse xmlns=”“>
<ProductDesc>5L Olive Oil Can</ProductDesc>             

<ProductDesc>FreshAir Gum</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
following code:

     message.setHeader(ODataExchangeHeaderProperty.SkipToken.toString(), token);

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
SMP server.

Now fire an OData Request https://localhost:8083/gateway/odata/SAP/SKIPTOKEN;v=1/ProductSet    on the browser and response will give the list of entries with link tag having a value similar to this: ?$skiptoken=’MYID’

The support of skipToken and its implementation depends on web service, so you will have to adapt this example for your specific service.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.