2016 Jan 29 9:29 AM
Hello,
I have a requirement to read data from given URL by 3rd Party e-commerce portal.
I have already use If_http_client, cl_http_client=>create_by_url, but unable to read data.
Can anyone help me regarding this issue.
Regards,
Rishabh.
2016 Jan 29 9:45 AM
How did you tried to read data?
What it means "unable to read data" ? Any exceptions, errors?
2016 Jan 29 9:58 AM
Hello Tomas,
Here is my Code,
DATA: l_http_client TYPE REF TO if_http_client.
DATA: lv_string TYPE xstring,
lv_content TYPE xstring,
lv_i TYPE i,
lv_url TYPE string VALUE 'https://abcdxyz.php'
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = l_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3.
CHECK sy-subrc = 0.
l_http_client->propertytype_logon_popup = l_http_client->co_disabled.
l_http_client->request->set_header_field( EXPORTING name = '~request_method'
value = 'GET' ).
*
l_http_client->request->set_header_field( EXPORTING name = '~server_protocol'
value = 'HTTP/1.0' ).
CALL METHOD l_http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CHECK sy-subrc = 0.
CALL METHOD l_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CHECK sy-subrc = 0.
l_http_client->response->get_status( IMPORTING code = lv_i ).
lv_string = l_http_client->response->get_data( ).
lv_content = lv_string.
Please Suggest.
Regards,
Rishabh
2016 Jan 29 9:59 AM
2016 Jan 30 7:04 AM
Love it. You ask
Tomas Buryanek wrote:
How did you tried to read data?
What it means "unable to read data" ? Any exceptions, errors?
and the OP responds with the code. But nothing about exceptions or errors.
2016 Jan 29 9:59 AM
Hi,
Try This .
call method cl_http_client=>create_by_url
exporting
url = 'httyp://abc.com/abc.xml'
importing
client = http_client.
http_client->send( ).
http_client->receive( ).
clear xml_out .
xml_out = http_client->response->get_cdata( ).
http_client->close( ).
Use FM SMUM_XML_PARSE to convert xml_out to internal table
Regards,
Sabir
2016 Jan 29 10:05 AM
Hi Sabir,
Thanks for your reply.
I have a URL which extension is .php so i have to read data from that only.
when i click on my URL then i got a numbers of records with ',' delimiter on browser.
regards,
Rishabh
2016 Jan 29 10:03 AM
2016 Jan 29 10:07 AM
Hi raymond,
I am getting 404 Not found Error.
Regards,
Rishabh.
2016 Jan 29 7:27 PM
2016 Jan 29 7:28 PM
Hi Rishabh,
did you try to copy and paste the link into your browser on the application server?
The 404 error simply means that the file specified by the link does not exist and maybe your frontend can access the internet, but not the backend.
Best regards,
Dominik
2016 Jan 30 7:42 AM
Hi Eitan,
I have tried your code also but your code is based on XML and my URL is .PHP.
so in my case it is not working.
Regards,
Rishabh
2016 Jan 30 7:45 AM
Hi Dominik,
Yes i have tried into browser and there i am getting data like notepad(.txt) format.
Best Regards
Rishabh.
2016 Jan 30 1:12 PM
Hi,
True.
My idea was to check if you can get something of the web.
Did the code work for you as is ?
Change the url to your url and put a break point here :
What is the content of field "response_string_1" ?
You wrote "i got a numbers of records with ',' delimiter on browser."
You need to write a code to parse those records.
Do a google using search operators: site:scn.sap.com parse csv file
Regards.
2016 Feb 01 4:55 AM
Hi Eitan,
I have tried your code as it is & URL also but i am getting SY-SUBRC = 1 after CALL METHOD client->receive.
Regards,
Rishabh.
2016 Feb 01 5:13 AM
Hi,
Looks like you have communication problem to the web.
This what I get:
Replace CONSTANTS: c_url TYPE string VALUE 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml' .
with some intranet link (https://en.wikipedia.org/wiki/Intranet)
2016 Feb 01 5:31 AM
Hi Eitan,
Sorry for Bother you but i am not getting what is the problem.
Regards,
Rishabh
2016 Feb 01 5:40 AM
Hi,
1 means http_communication_failure
please replace CONSTANTS: c_url TYPE string VALUE 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml' .
with some intranet link (https://en.wikipedia.org/wiki/Intranet) .
also talk with you basis team about the problem.
Regards.
2016 Feb 01 6:47 AM
Hi Eitan,
Thanks for your quick reply ,
we added host file to the server but still we are facing same problem
also replaced URL with local Intranet URL.
Best Regards,
Rishabh
2016 Feb 01 7:03 AM
Check if there is system message and what it says:
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Also this can get more info (probably same as in system message though):
cl_http_client=>get_last_error(
IMPORTING
code = code " Error Code
message = message " Error Message
).
But what Eitan already wrote. It looks like problem to solve for basis team.
2016 Feb 01 7:15 AM
Any Firewall ?
Any Proxy that can be used ?
Authority ?
Ask the basis to login to the application server and see if he can access the web from there.
Regards.
2016 Feb 01 9:49 AM
Hi Eitan,
I can´t find any proxy settings in my system, I looked into SICF->client->proxy settings, and everything is blank. Where should I see the setting you refer to? Should be there?
I´ll keep the research with the clue you gave to me, but I´ll be grateful if you could help me just a bit more.
Regards,
Rishabh.
2016 Feb 01 9:57 AM
Hi,
I am referring to proxy that might be in use in your network to get out to the web .
In my case it is the same proxy define in IE
2016 Feb 01 10:53 AM
Hi Eitan,
Which Servers are you running on and what is the OS, We are running on AIX and the problem is with the website since it keeps on changing the IP address.
Due to frequent change in IP address the servers are not able to resolve the web address.
Best Regards,
Rishabh.
2016 Feb 01 11:11 AM
Hi Tomas,
I am getting "Object <Program Name> of class RE and language EN does not exist"
error.
Regards,
Rishabh.
2016 Feb 01 11:15 AM
Hi,
It is a windows network .
The server is window server 2003 .
Regards.