Skip to Content

Gat a form and submit data using CL_HTTP_CLIENT

My knowledge of CL_HTTP_CLIENT is currently limited to creating a client using a url and getting the data using send and receive methods.

My requirement now is to get an html form using cl_http_client send, receive and then filling a field in the form and submitting the form to get the result. Could anyone enlighten me on how could I achieve this?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Sep 29, 2008 at 09:18 AM

    When an ABAP application program in the SAP system sends an HTTP request to a web server over the Internet, the following steps are performed :

    ● The ABAP application program creates an object of the class CL_HTTP_CLIENT (1).

    This is done by calling one of the following methods:CL_HTTP_CLIENT=>CREATE, CL_HTTP_CLIENT=>CREATE_BY_DESTINATION or CL_HTTP_CLIENT=>CREATE_BY_URL.

    This object is referred to here as the client control block (similarly to the server control block). The ABAP application program that sends the request calls the method.

    The structure of class CL_HTTP_CLIENT is described under Interface IF_HTTP_CLIENT.

    Note that the activities in points 2, 3, 5, 6, 7, 11, 12 and 13 must also be triggered by the ABAP application program, that is, by calling the appropriate methods. The ABAP application program therefore uses the components of the class CL_HTTP_CLIENT so that it can generate the request data and process the response data.

    ○ If you want the method CL_HTTP_CLIENT=>CREATE to be called, the following information must be provided for this method: HOST (host name),SERVICE (port), PROXY_HOST (host name of the proxy host), PROXY_SERVICE (port of the proxy host) and SCHEME (specifies whether HTTP or HTTPS should be used; has the default value u201CSCHEMETYPE_HTTPu201D). If you communicate using the SSL protocol (u201CSCHEMETYPE_HTTPSu201D), you can use the parameter SSL_ID to specify appropriate SSL certificates. If you want to use these certificates to log on to an ABAP Application Server, you can use SAP_USERNAME and SAP_CLIENT to specify the additional information that is required.

    If you want the method CL_HTTP_CLIENT=>CREATE_BY_DESTINATION to be called, you have to make the corresponding entries in transaction SM59 for the HTTP destination (node HTTP Connections to ABAP System or HTTP Connections to Ext.. Server). For details on the settings, see Connection Establishment Using Destination (SM59).

    There is a central configuration environment for making proxy settings in the system. To access it, call transaction SICF and choose Client -> Proxy Settings.

    ● The generated client control block is filled by filling the attribute Request with the required request data (2).

    ● The request is then sent using the method SEND (3). To do this, the connection is opened and the request is converted to a HTTP data stream (serialized).

    ● Task handlers and the Internet Communication Manager are used to send the request to the required HTTP server (4).

    ● If the HTTP server requires authentication (for example, if the server is also an SAP System), the client must now log on (5,6,7,8. If the server is also an SAP System, the client logs on via an SAP logon popup. Otherwise, the client logs on via the HTTP standard popup. The query whether the SAP logon popup or the HTTP standard popup should be used is executed within the method RECEIVE (see 6). If you do not want a logon dialog box for the application, you can disable it by specifying the value CO_DISABLED for the attribute IF_HTTP_CLIENT~PROPERTYTYPE_ LOGON_POPUP.

    This authentication is carried out in dialog processes, not in batch processes.

    If the service is not accessible with this URL, and the response includes a redirect, the ICF manager will redirect the request to the new URL. If you do not want the application to respond this way, you can disable it by specifying the value CO_DISABLED for the attribute IF_HTTP_CLIENT~PROPERTYTYPE_REDIRECT.

    If no proxy information has been specified, the ICF manager also evaluates the central proxy settings for the request. If you do not want the application to respond this way, you can disable it by specifying the value CO_DISABLED for the attribute IF_HTTP_CLIENT~ PROPERTYTYPE_APPLY_SPROXY.

    ● The HTTP server generates a response and sends it back (9,10). When the method RECEIVE is called, the response data is imported and the attribute RESPONSE for the control block is filled (10).

    ● The data is then processed or displayed by accessing the response attribute (11, 12).

    It is also possible to transfer the output to the HTML control. In this case, the response is displayed as it would be in a browser.

    ● Once the data has been displayed, the connection is closed using the method CLOSE (13).

    Once the method CLOSE has been executed, you can no longer access the Request and Response objects.

    Once the application has processed your requests and responses, the connection should be closed using the method CLOSE in order to avoid increased resource consumption.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 29, 2008 at 09:19 AM

    Interface IF_HTTP_CLIENT


    If the SAP system has the client role, interface IF_HTTP_CLIENT of class CL_HTTP_CLIENT is implemented. IF_HTTP_CLIENT serves as an interface for gaining access to data structures, so that request and response data can be processed. It also ensures communication between client and server, in this case from the perspective of the client.


    An object of the class CL_HTTP_CLIENT, a client control block, is created for every outgoing request, as described above. Like objects in class CL_HTTP_SERVER, this object contains the data structures IF_HTTP_REQUEST and IF_HTTP_RESPONSE for the HTTP request and HTTP response data. It also provides interface references in its own interface to these data structures: attributes REQUEST and RESPONSE: In this case, the response part is empty when the request is sent.

    The interface IF_HTTP_CLIENT contains its own attributes and methods, which are different from the server interface, or else do not occur there.

    Add comment
    10|10000 characters needed characters exceeded