01-19-2005 12:47 PM
Hi all,
i want to execute a URL ping from a ABAP function module but without any browser openning. I just want to check if the URL is correct and if it return true.
How can i do that ?
Regards,
Eric.
01-19-2005 12:57 PM
01-19-2005 1:42 PM
I'm using the WAS 6.20
But idon't want to open a browser and see the result of the URL ! i just want to know if the URL exist or not and / or if the server response is ok.
Eric.
01-19-2005 1:47 PM
You misunderstand. The HTTP client is the SAP server itself. ABAP is the language the client is written in. Nothing will show in a browser. The functionaly allows you to open a HTTP connection, make a request and receive a response. The response data and return code is brought back directly to the calling abap program. This is all part of the native HTTP stack (ICM - Internet Connection Manager) in the WebAS. For this to work you don't even need a connection to a frontend (it can work in batch).
01-19-2005 1:52 PM
No no i don't misunderstand anything !!
i understand what you write and it's exactly what i think about !!
So please have you got a simple example ABAP code to test this functionality ?
01-19-2005 1:57 PM
Yes here is the sample:
data: client type ref to if_http_client,
url type string.
****Build the Sending URL
concatenate
page_srv-send_url
`&Message=`
message
`&Class=`
class
`&Number=`
sms_number
`&Priority=`
priority
`&Project=`
page_srv-project_name
`&Sendingnumber=`
page_srv-sending_number
into url.
****Create the HTTP client
call method cl_http_client=>create_by_url
exporting
url = url
ssl_id = page_srv-ssl_id
importing
client = client
exceptions
others = 1.
****Set the Request type to GET
client->request->set_header_field( name = '~request_method'
value = 'GET' ). "#EC *
****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
p_content = client->response->get_cdata( ).
There is also a client->response->get_status( ) that you might find interesting. Check out the class definition to see the full range of options.
01-19-2005 1:59 PM
01-19-2005 2:07 PM
sorry but i don't understand the value "page_srv-ssl_id" i have to put in the method call "cl_http_client=>create_by_url".
01-19-2005 2:10 PM
You can ignore this. I had to use it because I was calling an HTTPS site. This field had a link to my client certificate. Not necessary if you are calling to HTTP. In case you are interested in the details of calling HTTPS the following weblog should help:
/people/thomas.jung3/blog/2004/11/17/bsp-a-developers-journal-part-xiv--consuming-webservices-with-abap
01-19-2005 3:02 PM
01-19-2005 1:59 PM
Eric Gourdou:
you have to implement javascript.
<html>
<head>
<title>welcome</title>
<script>function loadurl(url){window.open(url , "_self") }</script></head>
<body onload="javascript:loadurl('URL')">Loading . . . . . </body>
</html>
please save above code as html and speicify your url name instead of URL text.
then move to transaction SMW0 select HTML templates option for WebRFC application and then execute from the next screen. click create and give a object name, description then import the HTML file you have saved.
and use this function module in your ABAP code
call method html_control->load_html_document
Regards
Suresh Babu Karanam
01-19-2005 2:50 PM
Dear Suresh,
i don't understand what you mean by:
and use this function module in your ABAP code
call method html_control->load_html_document
how can i use my object created in the SMW0 transaction in a function module ?
could you please give me an eample !!
Eric.