For java.sap.sd/odata

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

Web service ABAP method (for /inbound-idoc):

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 ).

redefined MPC_EXT DEFINE Method:

 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

Добавить комментарий

All fields are required. Your email address will not be published.