Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Http request handler - Send response

konstantinos_vassiliadis
Active Participant
0 Likes
2,159

Dear experts,

I have an http communication - bidirectional - between SAP and a non-SAP system. In the direction from non-SAP to SAP, I defined a request handler using SE24 and SICF. Communication works fine.

My problem is to send a response from SAP to the non-SAP system. I see that SERVER input parameter of implemented method HANDLE_REQUEST gives access to the response object by calling IF_HTTP_SERVER->RESPONSE. To set the data of the response there is

      IF_HTTP_RESPONSE->SET_DATA by passing xstring as input parameter.

What I do not understand is how to actually send these data to the client - the non-SAP system that originally sent a request to SAP. I see no send mehod in IF_HTTP_SERVER, there is only a method SEND_PAGE but I am not sure this is the right one.

Kind regards,

Konstantinos

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,612

Hi,

Not sure if it helps or not. But a pointer may be.

Did you check class CL_HTTP_SERVER method SEND_RESPONSE .

This class has used the interface IF_HTTP_SERVER , so ideally you can cast the instance of IF_HTTP_SERVER and call the method .

R

4 REPLIES 4
Read only

Former Member
0 Likes
1,613

Hi,

Not sure if it helps or not. But a pointer may be.

Did you check class CL_HTTP_SERVER method SEND_RESPONSE .

This class has used the interface IF_HTTP_SERVER , so ideally you can cast the instance of IF_HTTP_SERVER and call the method .

R

Read only

0 Likes
1,612

Thanks a lot Rudra!

however I have the following code, not sure how to do it properly

* the following line is the importing parameter to class which is the http request handler

* and thus implements interface IF_HTTP_EXTENSION

* SERVER TYPE REF TO IF_HTTP_SERVER

FIELD-SYMBOLS: <ls> type REF TO CL_HTTP_SERVER.


................


ASSIGN server to <ls> CASTING.


which gives error when activating:


"<LS>" and "SERVER" contain references, internal tables, or strings. In

the current statement, these must occur at the same offset position and

they must be compatible.


How can I properly cast SERVER to type CL_HTTP_SERVER so that I use SEND_RESPONSE method?


Konstantinos

Read only

0 Likes
1,612

FYI I used the following code

  data:  lcl_cl_http_server type REF TO cl_http_server.

.......................

  lcl_cl_http_server ?= server.     "<-- widening cast

   CLEAR: lv_rc.

   CALL METHOD lcl_cl_http_server->SEND_RESPONSE

     RECEIVING

       RC                 = lv_rc.


    

and it seems to have worked (lv_rc is returned zero and the response was sent to client)

Read only

0 Likes
1,612

Yeah, That is the way to cast using "?=" in ABAP.

Glad to hear it worked.