cancel
Showing results for 
Search instead for 
Did you mean: 

Error when trying to run IF_HTTP_CLIENT->RECEIVE()

Former Member
0 Kudos

Hi experts,

I nedd to retrieve a file from any given URL (i.e. http://www.google.com/images/nav_logo4.png) and save it.

I thought that calling if_http_client->receive() method would be ideal, but when I call it I´m always getting exception 'http_communication_failure'.

Transaction SMICM looks good...what else should I check?

I give my source code:


data: client  type ref to if_http_client,
      content type string.


****Create the HTTP client
cl_http_client=>create_by_url( exporting url = 'http://www.google.com/images/nav_logo4.png' 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
  content = client->response->get_cdata( ).

Thanks for your help.

Regards,

Federico

Accepted Solutions (0)

Answers (9)

Answers (9)

Former Member
0 Kudos

Thanks everybody, after driving me crazy, IT people told that Hosting people have completely isolated SAP servers from internet.

It was NEVER gonna work...

Regards,

Federico.

Former Member
0 Kudos

More info that could be useful:

I raised the trace level of ICM, and when I call my code, this what the log returns (part of it):


[Thr 14] *** WARNING => IcmCheckForBlockedThreads(id=8/95195): forced shutdown of nihdl 27 connected to 192.168.79.17:53893 on b
[Thr  4] IcmGetSchedule: found slot 0
[Thr  4] IcmAlReportData: Reporting data to CCMS Alerting Infrastructure
[Thr 14] NiIShutdownHandle: hdl 27 not connected anymore (socket 48; howTo=2; sirc=1; errno=22)
[Thr 14] NiIShutdownHandle: shutdown rw of hdl 27
[Thr 14] *** WARNING => IcmCheckForBlockedThreads(id=13/98258): forced shutdown of nihdl 8 connected to 192.168.79.17:57233 on b
[Thr 14] NiIShutdownHandle: hdl 8 not connected anymore (socket 35; howTo=2; sirc=1; errno=22)
[Thr  4] NiIGetServNo: servicename '8000' = port 1F.40/8000
[Thr 14] NiIShutdownHandle: shutdown rw of hdl 8
[Thr  4] IcmConnCheckStoredClientConn: next client timeout check in 1 sec
[Thr 14] *** WARNING => IcmCheckForBlockedThreads(id=5/39368): forced shutdown of nihdl 16 connected to 192.168.79.17:61158 on b
[Thr  4] NiIGetServNo: servicename '8000' = port 1F.40/8000
[Thr 14] NiIShutdownHandle: hdl 16 not connected anymore (socket 47; howTo=2; sirc=1; errno=22)
[Thr  4] IcmGetServicePtr: new serv_ref_count: 2
[Thr 14] NiIShutdownHandle: shutdown rw of hdl 16

Over and over again...

Please help!

Thanks.

athavanraja
Active Contributor
0 Kudos

one more try. can you run program RSHTTP01 with the following options

host: http://www.google.com

service: 80

path: /images/nav_logo4.png

when you run , do you get a authentication pop up?

if you just cancel what happens?

Regards

Raja

Former Member
0 Kudos

Well, I got this:

SMICM looks good. Everything in GoTo->Services appears as 'active'. However, column External bind is blank...

In SICF, testing that service returns 'Server reached successfully' in a browser window.

So...I have a network security issue?

Thanks!

Regards,

Federico.

Former Member
0 Kudos

Thanks once more, Graham.

It´s curious, even with a local URL it returns ' ICM_HTTP_CONNECTION_FAILED'.

I´ll ask basis guys, network security guys, and whoever should know. But I´m listening since now 'it´s an ABAP program, not our bussiness'

Anyway, if sometinhg else comes to your mind, let me know. I´ll be very gateful.

Regards,

Federico.

GrahamRobbo
Active Contributor
0 Kudos

Okay that is strange. Perhaps your ICM is not running?

You can check this in transaction SMICM. Click on Goto->Services to see which TCP/IP port it is running on and it should have a green tick showing it is active.

If it is working okay then BSP pages and Web Dynpro ABAP applications should run okay.

In transaction SICF navigate to service default_host->sap->public->ping and test the service. You should get a page that says "Server reached successfully".

If none of this works then get your Basis guys onto the job - and cancel the call to the network guys.

Cheers

Graham Robbo

Former Member
0 Kudos

Dear Graham:

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...

Thanks in advance,

Cheers

Federico.

GrahamRobbo
Active Contributor
0 Kudos

It still sounds to me like a network proxy or authentication issue. Just because your web browser doesn't have an entry for a proxy server doesn't mean your network doesn't still route all HTTP traffic to a proxy server automatically.

Try and call a URL that is located inside your network - even better one that is on your SAP application server so you can use a URL like

http://localhost/test.html

to be certain your HTTP request must get through.

If that works, and I think it will, then have a chat to your network admin guys to find out what is going on.

Cheers

Graham Robbo

Former Member
0 Kudos

Thank you all, guys.

No I don´t use a proxy.

Something new: I ran standard report RSHTTP20 (which uses FM HTTP_GET), giving only my test URL as parameter (http://www.google.com/images/nav_logo4.png), and it worked.

This is the result:


HTTP GET Test

200 OK                                                                   40,909  ms


HTTP/1.0 200 OK
Content-Type: image/png
Last-Modified: Wed, 11 Feb 2009 03:40:02 GMT
Date: Sat, 16 May 2009 04:59:00 GMT
Expires: Sun, 16 May 2010 04:59:00 GMT
Cache-Control: public, max-age=31536000
Server: gws
Content-Length: 7121
Age: 1260216

...image binary data...

Why when I try to do the GET through IF_HTTP_CLIENT->SEND / RECEIVE, I receive an error, and when I use this function module i don´t?

Thanks in advance.

Regards.

Federico

GrahamRobbo
Active Contributor
0 Kudos

The program RSHTTP20 calls HTTP_GET without passing any proxy parameters. Perhaps you have invalid proxy settings in your WAS?

I just copy and pasted your code directly into my system and it worked fine. When I configured invalid proxy settings I got the HTTP 400 status.

Cheers

Graham Robbo

Former Member
0 Kudos

Thanks Graham.

I can acces the URL in my browser with no problems.

Regards,

Federico.

GrahamRobbo
Active Contributor
0 Kudos

That means nothing - it is not your browser that is trying to access the URL it is the SAP Web Application Server.

Cheers

Graham Robbo

athavanraja
Active Contributor
0 Kudos

do you connect to those sites from your browser via proxy? if yes you may have to authenticate via proxy

Former Member
0 Kudos

Also:

I ran program RSHTTP05 with following results:


SAPHTTP check

Check RFC destination SAPHTTP...
... OK.
Ping RFC destination SAPHTTP...
... OK.
Check RFC destination SAPHTTPA...
... OK.
Ping RFC destination SAPHTTPA...
... OK.

I thougt it could help.

Regards...

Former Member
0 Kudos

One more thing:

I added the following code to get more details about the error:


CALL METHOD client->receive
  EXCEPTIONS
    http_communication_failure = 1
    http_invalid_state         = 2
    http_processing_failed     = 3
    OTHERS                     = 4.
IF sy-subrc NE 0.
  DATA subrc TYPE sysubrc.
  DATA errortext TYPE string.

  CALL METHOD client->get_last_error
    IMPORTING
      code    = subrc
      MESSAGE = errortext.

  WRITE: / 'communication_error( receive )',
         / 'code: ', subrc, 'message: ', errortext.
  EXIT.
ELSE.
****Get the response content in Character format
  content = client->response->get_cdata( ).
ENDIF.

And I get:

"communication_error( receive )

code: 400 message: ICM_HTTP_CONNECTION_FAILED"

Any idea of what is happening?

Thanks.

Federico.

GrahamRobbo
Active Contributor
0 Kudos

Sounds like your HTTP request is not getting through to the HTTP server.

This could be a proxy server or network security issue. Try and access a URL inside your network first.

Cheers

Graham Robbo