I have created OData service in SEGW and published it.
There are two case :
1.)With CSRF token —
By Default Gateway will generate the CSRF token, if any of CUD(Create, Update and Delete) operation we are doing it is mandatory to pass this token(CSRF ).
So before any CUD operation, Retrieve a CSRF token with a non-modifying request(get method).
Validity of this Token is 30 mins (which can further be altered by Tcode RZ11(Parameter : http/security_session_timeout) might be there is some diffrent mecanism as well
Fetching mechanism : In client side need to put one parameter X-CSRF-Token(‘X-CSRF-Token’) with the value ‘Fetch’ is sent along with the non-modifying request.
2.) Without CSRF token —
without CSRF first we need to override standard behavior of service, in SICF node for each service need to maintain parameter in GUI configuration as below :
Parameter Name: ~CHECK_CSRF_TOKEN
Parameter Value: 0/1 (disable/enable)
And At client level in Header need to pass X in Header
(‘X-Requested-With’: ‘X’)
Requested URI: /sap/opu/odata/sap/mein-dienst/infosatzSet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?xml version="1.0" encoding="utf-8"?> <entry xml:base="http://sapondev100.sap.sd/sap/opu/odata/sap/zz_record/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"> <id>http://sapondev100.sap.sd/sap/opu/odata/sap/zz_record/infosatzSet(1)</id> <title type="text">infosatzSet(1)</title> <updated>2000-01-01T01:01:01Z</updated> <category term="zz_record.infosatz" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/> <link href="infosatzSet(1)" rel="self" title="infosatz"/> <content type="application/xml"> <m:properties> <d:Index>43</d:Index> <d:Kschl>unas</d:Kschl> </m:properties> </content> </entry> |
Web service ABAP method (for /inbound-idoc):
method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY. data ir_deep_entity type zz_record_mpc_ext=>ts_deep_entity. io_data_provider->read_entry_data( IMPORTING es_data = ir_deep_entity ). copy_data_to_ref( exporting is_data = ir_deep_entity changing cr_data = er_deep_entity ). endmethod.
redefinde MPC_EXT DEFINE Method:
data: lo_annotation TYPE REF TO /iwbep/if_mgw_odata_annotation, lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ, lo_complex_type TYPE REF TO /iwbep/if_mgw_odata_cmplx_type, lo_property TYPE REF TO /iwbep/if_mgw_odata_property, lo_entity_set TYPE REF TO /iwbep/if_mgw_odata_entity_set. super->define( ). lo_entity_type = model->get_entity_type( iv_entity_name = 'E_Kopf' ). " Pos lo_entity_type->bind_structure( iv_structure_name = 'zz_record_mpc_ext=>ts_deep_entity' ).
MPC_EXT Types:
* variable names should be same as of 'Navigation Property' name created * in Entity 'Kopf' / 'Pos' else structure can not be referred in code. * types: " (create in MPC_EXT Class) * begin of ts_deep_entity, * kopf type standard table of ts_infosatz with default key, * pos type standard table of ts_staffelpos with default key, * end of ts_deep_entity. types: ty_t_soitem type standard table of zz_record_mpc=>ts_staffelpos with default key. *" Represents full - header with one of more items types: begin of ty_s_so. include type zz_record_mpc=>ts_infosatz. types: SOItems type ty_t_soitem, end of ty_s_so. data: ls_so type ty_s_so, ls_item type zz_record_mpc=>ts_staffelpos.
Debug OData requests: blogs.sap.com/2016/10/29/method-not-allowed-error-trouble-shoot