REPORT zsuhas.
*HTTP Client Abstraction
DATA lo_client TYPE REF TO if_http_client.
*Data variables for storing response in xstring and string
DATA : lv_xstring TYPE xstring,
lv_string TYPE string,
lv_node_name TYPE string.
CLEAR : lv_xstring, lv_string, lv_node_name.
*Put required node name into constant (case sensitive)
CONSTANTS : co_req_node TYPE string VALUE '<YOUR_REQUIRED_NODE_NAME>'.
*Creation of New IF_HTTP_Client Object
cl_http_client=>create_by_url(
EXPORTING
url = "URL
proxy_host = "Proxy
proxy_service = "Port
sap_username = "Username
sap_client = "Client
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
).
IF sy-subrc IS NOT INITIAL.
* Handle errors
ENDIF.
*Structure of HTTP Connection and Dispatch of Data
lo_client->send( ).
IF sy-subrc IS NOT INITIAL.
* Handle errors
ENDIF.
*Receipt of HTTP Response
lo_client->receive( ).
IF sy-subrc IS NOT INITIAL.
* Handle errors
ENDIF.
lo_client->propertytype_logon_popup = lo_client->co_disabled.
data l_username type string.
data l_password type string.
l_username = MY_USERNAME.
l_password = MY_PASS.
lo_client->authenticate(
exporting
proxy_authentication = 'X'
client = Client " R/3 System, client number from logon
username = l_username " ABAP System, User Logon Name
password = l_password " Logon ID
* language = language " SAP System, Current Language
).
*Return the HTTP body of this entity as binary data
lv_xstring = lo_client->response->get_data( ).
*Displays XML File
CALL METHOD cl_abap_browser=>show_xml
EXPORTING
xml_xstring = lv_xstring
size = cl_abap_browser=>large.
*Create the factory object
DATA(lo_ixml) = cl_ixml=>create( ).
*Create a factory for input and output streams
DATA(lo_stream_factory) = lo_ixml->create_stream_factory( ).
*Create input stream for data source byte string
DATA(lo_istream) = lo_stream_factory->create_istream_xstring( string = lv_xstring ).
*Create an XML document in DOM format
DATA(lo_document) = lo_ixml->create_document( ).
*Create a parser
DATA(lo_parser) = lo_ixml->create_parser(
stream_factory = lo_stream_factory
istream = lo_istream
document = lo_document ).
DATA(lv_rc) = lo_parser->parse( ).
IF lv_rc <> ixml_mr_parser_ok.
* ... "Error handling
RETURN.
ENDIF.
DO.
DATA(req_node) = lo_iterator_req->get_next( ).
IF req_node IS INITIAL.
EXIT.
ENDIF.
*Returns the node type
DATA(lv_nodetype) = req_node->get_type( ).
*Name
IF lv_nodetype = if_ixml_node=>co_node_element. "Element
IF req_node->get_name( ) NE co_req_node.
WRITE : req_node->get_name( ).
WRITE : ':'.
ENDIF.
ENDIF.
*Value
IF lv_nodetype = if_ixml_node=>co_node_text OR lv_nodetype = if_ixml_node=>co_node_cdata_section. "Literal Text/CDATA Section
WRITE : req_node->get_value( ).
SKIP.
ENDIF.
ENDDO.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |