Skip to content

A minimal app that displays data from the SAP demo OData service GWSAMPLE_BASIC

Notifications You must be signed in to change notification settings

ChrisWhealy/parse-sap-odata-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo App for Reading SAP OData Service GWSAMPLE_BASIC

This is a minimal demo app that starts an Actix webserver to request data from the selected entity set in SAP's demo OData service GWSAMPLE_BASIC.

It does this in the following stages:

  1. Runs a build script that consumes the XML metadata description of GWSAMPLE_BASIC (see the functionality in crate parse-sap-odata)
  2. Generates a file called gwsample_basic.rs containing the module gwsample_basic
  3. Using the generated structs and enums, the atom:Feed information exposed as entitysets in this OData service can then be consumed.

In this minimal demo scenario, the parsed entity set data is simply returned to the browser as formatted, plain text.

Prerequisites

You must already have a userid and password for the SAP Dev Center server sapes5.sapdevcenter.com

  1. Clone this repo

  2. cd parse_sap_odata_demo

  3. Create a .env file containing your SAP DevCenter userid and password in the following format

    SAP_USER=<your userid>
    SAP_PASSWORD=<your password>
    

Local Execution

Once the .env file has been created, you can start the app using cargo run.

Visit http://localhost:8080 and you will see a simple drop down list containing the entity sets available on the GWSAMPLE_BASIC OData service.

Start screen

Select the desired entity set and the first 100 entries will be displayed in plain text. This output comes from the Rust println!() macro printing the Rust struct into which the entity set data has been parsed.

Known Issues/Workarounds

Invalid ETag Attribute Values

When calling the SAP demo OData service GWSAMPLE_BASIC, various entity sets (such as BusinessPartnerSet and ProductSet) return <entry> tags whose m:etag attribute contains a value that is not in valid XML format.

The raw XML will contain m:etag attributes with values like this:

<entry m:etag="W/"datetime'2023-08-31T01%3A00%3A06.0000000'"">

The extra "W/ characters at the start and the extra " character at the end are invalid XML and may cause an XML parser to throw its toys out of the pram. So, before parsing the raw string containing this XML, such invalid values are checked for and removed.

In this case, the above m:etag value is sanitised to:

<entry m:etag="datetime'2023-08-31T01%3A00%3A06.0000000'">

Naked Ampersand Characters

Certain text descriptions are provided that contain an unescaped (or naked) ampersand character. For example:

<d:Category>PDAs & Organizers</d:Category>
<d:Landx>St Kitts&Nevis</d:Landx>

In order to stop the XML parser from barfing, this character must be replaced with its character encoding:

<d:Category>PDAs &amp; Organizers</d:Category>
<d:Landx>St Kitts&amp;Nevis</d:Landx>

About

A minimal app that displays data from the SAP demo OData service GWSAMPLE_BASIC

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published