‎2009 May 07 8:26 PM
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..
‎2009 May 08 10:04 AM
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
‎2009 May 08 10:24 AM
>
> 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.