ODATA
ODATA is the means to create one kind of RESTFUL API.
API is a code that allows two S/W programs to communicate with each other.
RESTFUL – representational state transfer is a style of developing web services.
In contrast to SOAP which is action based (get an employee, get a product, get sales order), REST is resource based (employee, product, sales order).
REST Principles
1. Everything is a resource and it is identified by URI (unique resource identifier) which is a form or URL.
URL: hostname: port no of hub/service name/resource name
2. When a resource is requested a representation or copy is sent in XML or JSON format
REST Constraints
1. Uniform Interface – Architecture can evolve independently. Separation of display and business logic. Irrespective of display logic, business logic uses following HTTP methods.
a. Create -> POST
b. Read ->GET
c. Update->PUT
d. Delete->DELETE
2. Stateless – After server sends a response to a request, it does not hold a session or user-related information.
3. Client Server-Uniform interface separates client & server, as a result, frontend can be replaced easily, flexibility to customers to choose UI of their own choice
4. Cacheable – Cache memory can hold server response
5. Layered system – Client should not assume it interacts with the server directly, there can be middle layers
SAP NetWeaver Gateway
Simple way to connect devices, environments & platforms to SAP s/w.
SAP Gateway Service Builder:
TCode : SEGW
Below 7.4
1. Gateway core -GW_CORE
2. Business enablement provisioning -IW_BEP
3. Foundation- IW_FND
Above 7.4
SAP_GWFND -> Gateway foundation
Possible architecture
1. Hub architecture (Gateway hub where service is built in a separate system than business suite where implementation is done)
2. Embedded architecture (both service and implementation in the business suite)
Standard Steps
1. The consumer sends HTTP request
2. Registered service in the gateway is called (/IWEND/MAINT_SERVICE)
3. ODATA service called through RFC from the backend
Entity data model
1. Entity type: required structure/ bunch of named properties with associated data types
2. Entity: Instance of entity type
3. Association
4. Entity Sets: Set of Entity records
Design Approach
1. Create a structure with required fields.
2. Create an ODATA project in SEGW
A project has
a. Data model: Entity type, Association, Entity Sets
b. Service implementation
c. Runtime Artifacts
d. Service maintenance
3. In data model import the created structure, choose key fields
4. Generate runtime artifacts.
It creates the following:
a. Model provider class (_MPC, _MPC_EXT)
i. MPC is the runtime object for design time modeling
ii. MPC extension is used when design-time environment needs to be changed at runtime. Redefine the method.
b. Data provider class (_DPC, _DPC_EXT)
i. <Entity_Set>_create_entity ->HTTP POST
ii. <Entity_Set>_delete_entity ->HTTP DELETE
iii. <Entity_Set>_update_entity ->HTTP PUT
iv. <Entity_Set>_get_entity ->HTTP GET
c. Service registration (_MDL, _SRV)
5. Register service
a. Using tcode /IWFND/MAINT_SERVICE, add the service
b. It creates a SICF node which is needed for all web based apps
6. Gateway client
a. Using tcode /IWFND/GW_CLIENT test a service
b. URI path:
Hostinfo/path/servicename
Modeling Techniques
1. Inside Out
Create service out of existing business component (function module, classes)
2. Outside In
Look at service/ app first, then think of business component to fulfill a need., if business component is not optimized then don’t use it. Go for the custom component. UI enforces business logic here
No comments:
Post a Comment