atom:Feed
This is a work in progress!
The crate is designed to work in conjunction with the source code generated from the crate parse-sap-odata
.
Crate parse-sap-odata
is invoked by a Rust build script to parse an OData XML metadata file and generates the Rust struct
s and enum
s needed to consume the entity set data described by that metadata.
This crate parse-sap-atom-feed
then makes use of the struct
s and enum
s generated above and allows your business app to consume the XML returned when requesting entity sets from this OData service.
You want to develop a Rust application that can consume the entity set data exposed by an SAP OData V2 service.
For the purposes of instruction, let's say you're working with a custom OData service that displays services order either by functional location or by date:
| | |
|---|---|
| Rust Application | zcustom-service-orders
| OData Service URL | https://my-sap-server.my-domain.com/sap/opu/odata/sap
| OData Service Name | ZCUSTOM_SERVICE_ORDERS_SRV
| OData Schema Name | ZCUSTOM_SERVICE_ORDERS
| Entity Names | SERVICE_ORDERS_BY_FLOC
SERVICE_ORDERS_BY_DATE
| Entity Type | ZServiceOrder
The general approach to consuming such a service is as follows:
cargo new zcustom-service-orders
cd zcustom-service-orders
Edit Cargo.toml
to include at least the following dependencies
```rust
[build-dependencies]
parse-sap-odata = "1.1"
[dependencies] chrono = { version = "0.4", features = ["serde"]} parse-sap-atom-feed = "0.1" rust_decimal = "1.30" serde = { version = "1.0", features = ["derive"] } uuid = { version = "1.4", features = ["serde"]} ```
mkdir odata
https://my-sap-server.my-domain.com/sap/opu/odata/sap/ZCUSTOM_SERVICE_ORDERS_SRV/$metadata
zcustom_service_orders.xml
in the odata
directoryCreate a build.rs
file in same directory as Cargo.toml
and add at least the following:
```rust
use parsesapodata::parser::gen_src;
fn main() { gensrc("zcustomserviceorders", "ZCUSTOMSERVICE_ORDERS"); } ```
In src/main.rs
include at least:
```rust
use parsesapatomfeed::{
Feed,
xml::sanitisexml,
};
include!(concat!(env!("OUTDIR"), "/zcustomservice_orders.rs"));
fn main() { let raw_xml: String = /* Whatever code is needed to fetch the entity set data as a raw XML string */;
// You might need to sanitise the raw XML string before attempting to parse it let cleanxml = sanitisexml(raw_xml);
let srvordersbyfloc = Feed::