cancel
Showing results for 
Search instead for 
Did you mean: 

Pushing JSON from ICF Service to cross domain service URL

Former Member
0 Kudos

Hi Experts,

I have a scenario where i need to push JSON to cross domain service URL through Http response in SAP ICF service.

I am using interface-IF_HTTP_EXTENSION to push json to other service.

Regards,

Sid

Accepted Solutions (1)

Accepted Solutions (1)

daniel_paulsen
Active Contributor
0 Kudos
Former Member
0 Kudos

Hi Daniel,


Thanks for your faster reply.But it not addressing my issue so i have given sample code for your better understanding.


METHOD if_http_extension~handle_request.

* Variables

  DATA: l_verb      TYPE string,

        l_path_info TYPE string,

        l_resource  TYPE string,

        l_param_1   TYPE string,

        l_param_2   TYPE string.

* Retrieving the request method (POST, GET, PUT, DELETE)

  l_verb = server->request->get_header_field( name = '~request_method' ).

* Retrieving the parameters passed in the URL

  l_path_info = server->request->get_header_field( name = '~path_info' ).

 


CLEAR: ls_contact,ls_response,l_rc.

*     Retrieve form data

      ls_contact-email     = server->request->get_form_field('empno').

      ls_contact-firstname = server->request->get_form_field('name').

      ls_contact-lastname  = server->request->get_form_field('phone_no').

  CREATE OBJECT lo_json_serializer

    EXPORTING

      DATA = ls_contact. " Data to be serialized

* Serialize ABAP data to JSON

  CALL METHOD lo_json_serializer->serialize.

* Get JSON string

  CALL METHOD lo_json_serializer->get_data

    RECEIVING

      rval = lv_json.

* Sets the content type of the response

  CALL METHOD server->response->set_header_field( name = 'Content-Type'

    value = 'application/json; charset=iso-8859-1' ).

* Returns the results in JSON format

  CALL METHOD server->response->set_cdata( data = lvjson ).


Note: I want to send the JSON (lv_json) to cross domain service URL(http:localhost:8080/new/data) using post method.

ENDMETHOD.

Regards,

Sid

daniel_paulsen
Active Contributor
0 Kudos

ah, I see.   It seems you've posted on the wrong forum as this one relates to SAP BI (Business Objects) restful web services.

You can try posting in ABAP the  forum or SAPUI5 forum.

Dan

Answers (0)