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 post from ABAP using Object Oriented method

Former Member
0 Likes
720

Hi ,

I want to call HTTP from ABAP. I came to know that using classes & objects is the best way to fulfill it.

Interface:

xml_document type ref to cl_xml_document

method post_xml_document.

data: client type ref to if_http_client,

xml_response type ref to cl_xml_document.

data: xml_string type string,

xml_xstring type xstring.

data: zsubrc type sy-subrc.

cl_http_client=>create_by_url( exporting url = 'http://www.example.com/post-url.xml' importing client = client exceptions others = 1 ).

client->request->set_header_field( exporting name = '~request_method' value = 'POST' ).

client->request->set_header_field( exporting name = '~server_protocol' value = 'HTTP/1.1' ).

client->request->set_header_field( exporting name = 'Content-Type' value = 'text/xml' ).

xml_document->render_2_string( exporting pretty_print = 'X' importing stream = xml_string ).

client->request->set_cdata( exporting data = xml_string offset = 0 ).

client->authenticate( exporting proxy_authentication = space username = 'username' password = 'password' ).

client->send( exceptions http_communication_failure = 1 http_invalid_state = 2 ).

client->receive( exceptions http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 ).

xml_xstring = client->response->get_data( ).

zsubrc = xml_response->parse_xstring( stream = xml_xstring ).

endmethod.

Above code can be used to do my work.

Apart from the code in ABAP, what are the configurational setting that we need to do ?

Thanks,

Shivaa..

2 REPLIES 2
Read only

Former Member
0 Likes
415

hi shiva,

apart from usin the code u should have configured the RFC destination

of type Http to external system and check the connection from transaction SICF u cna take basis help

and also check the proxy fire walls from ur environment to target ,

regards

afzal

Read only

0 Likes
415

>

> apart from usin the code u should have configured the RFC destination

Thats nonsense, create_by_url does not need an rfc connection. TA SICF is correct.