Get Example source ABAP code based on a different SAP table
VX_EXA_ONLY
ABAP_ICF - Calling an HTTP Service This example demonstrates how an ICF> HTTP service is called directly using a Web browser.
ABAP_SOURCE_CODE DEMO CL_DEMO_HTTP_SERVICE
ABAP_DESCRIPTION Any HTTP service defined in the service transaction SICF>> can be tested here. If the URL of the service is known, it can be called from the Internet, for example by entering an address in a browser. In this example, a service of this type is called using a generated webpage, which contains a link to the URL of the service. The URL is constructed from the host and port of the current ABAP_ASINSTANCE , the path in the service tree, and a form field. The host and port are filled using the method CL_HTTP_SERVER=>GET_LOCATION>. The form field carrid> is filled with the content of a field filled previously by user input. When this link is chosen, the browser displays the HTML page returned by the service. The content of the form field carrid> can be modified in the input field of the browser, to display different data. The called HTTP service is defined as the node /sap/bc/abap/demo> in the transaction SICF>>. The assigned HTTP request handler is the class CL_HTTP_EXT_SERVICE_DEMO>>. If a form field ... carrid=... > is added to the URL of the service, the content of this field is used as a key for selecting associated data from the database table SPFLI>. This is achieved by the class CL_HTTP_EXT_SERVICE_DEMO > implementing the interface IF_HTTP_EXTENSION>> and its method HANDLE_REQUEST>. This method is called by ICF and a reference is passed to a server object that implements the interface IF_HTTP_SERVER>>. The attributes REQUEST> and RESPONSE > of this interface refer to objects, which are implemented by the interfaces IF_HTTP_REQUEST>> or IF_HTTP_RESPONSE>>. The REQUEST > object is used to read the form field. The RESPONSE> object returns the result. METH CL_HTTP_EXT_SERVICE_DEMO=>IF_HTTP_EXTENSION~HANDLE_REQUEST The built-in function escape>> and the method ESCAPE_QUOTES> of the class CL_ABAP_DYN_PRG>> are using to prevent cross site scripting> and SQL injections>. The content of the internal table connections> (filled in accordance with the passed form field) is converted to HTML using the class CL_DEMO_OUTPUT>> before it is passed to the RESPONSE> object.
Latest notes: The HTTP service must be activated in transaction SICF>> before the example can work. ABAP_HINT_END