Application Development 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: 

How to download xml file from http:// (url) and then parse it (istrem).

Former Member
0 Kudos

Hi,

how Can I resolve downloading xml file from http server (internet) and built istream -> parse xml file. I build istream from itab but i would like whole process solve in abap code because i just use function ws_upload. If i try use

create_istream_uri( 'http://www.edi.com/file.xml' ) it doesnt work. Till now I must download xml file from this url manualy a then use this function and parse it, .....

*CALL FUNCTION 'WS_UPLOAD'

  • EXPORTING

  • filename = lv_file_url

  • filetype = 'BIN'

  • IMPORTING

  • filelength = xml_table_size

  • TABLES

  • data_tab = xml_table

  • EXCEPTIONS

  • OTHERS = 11.

ixml = cl_ixml=>create( ).

streamfactory = ixml->create_stream_factory( ).

*istream = streamfactory->create_istream_itable( table = xml_table

  • size = xml_table_size ).

Thanks, zd.

1 REPLY 1

Former Member
0 Kudos

Hai triska,

Check out the code from

/people/thomas.jung3/blog/2005/07/01/bsp-create-a-weather-magnet-using-xml-feed-from-weathercom

Adjust with the formating of the Blog.


data: url type string. 
data: t_url type string. 
data: client type ref to if_http_client. 
data: c_xml type string. 

concatenate `http://xoap.weather.com/weather/local/` `` `47546` `?cc=*&prod=xoap&par=XXXXXXXXXX` `&key=XXXXXXXXXXXXXX` into url.

****Create the HTTP client call method 
cl_http_client=>create_by_url 
exporting 
url = url 
host_compatibility = abap_true 
importing client = client 
exceptions others = 1. 

****Make the call 
client->send( ). 
****Receive the Response Object call method 
client->receive 
exceptions 
http_communication_failure = 1 
http_invalid_state = 2 
http_processing_failed = 3 
others = 4. 

****Get the response content in Character format 

c_xml = client->response->get_cdata( ). 

regards,

Venkatesh