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: 

Unable to connect https url

former_member291753
Participant
0 Kudos

Hi  experts,

Iam trying to connect with https url  but raising exception communication failure while calling method  http_client->receive.

iam using below code.

CALL METHOD cl_http_client=>create
   EXPORTING
     host               = 'https://XXXX.aspx'
     service            = '443'
*    proxy_host         =
*    proxy_service      =
     scheme             =  '2'
*    ssl_id             =
*    sap_username       =
*    sap_client         =
   IMPORTING
     client             = http_client
   EXCEPTIONS
     argument_not_found = 1
     plugin_not_active  = 2
     internal_error     = 3
     others             = 4
         .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

     http_client->request->set_header_field( name = 'Authkey'
                                value = 'ZmV4dFIz' ).

CALL METHOD http_client->request->set_cdata
     EXPORTING
       data = w_string.

CALL METHOD http_client->send
     EXCEPTIONS
       http_communication_failure = 1
       http_invalid_state         = 2.

     CALL METHOD http_client->receive
       EXCEPTIONS
         http_communication_failure = 1
         http_invalid_state         = 2
         http_processing_failed     = 3.

12 REPLIES 12

Former Member
0 Kudos

Ask your Basis guy if HTTPS service is enabled in your system.

You can achieve this at TCODE SMICM -> GoTo > Services.

0 Kudos

HI Heber

HTTPS is enabled

0 Kudos

Are you trying the connection from an enterprise site? Aren't you behind a proxy?

Maybe you should fill the proxy settings when creating the connection.

Could you check it please?

former_member184958
Active Participant
0 Kudos

Hi,

Try to pass the url in capital letter.

Regards,

John.

0 Kudos

Hi John ,

Tried in Capital letter also.But error remains same. 'Communication Failure'.

0 Kudos

Hi Raghu,

Go through the below link, it may helpful to you.

http://help.sap.com/saphelp_nwpi711/helpdata/en/48/c7c53bda5e31ebe10000000a42189b/content.htm

https://scn.sap.com/thread/1690117 - Good discussions.

Regards,

John.

venkateswaran_k
Active Contributor
0 Kudos

Dear Raghu,

1.   Try uncomment the following and test it as what is the message you are getting.

IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

2.  Please verify the user-id and password again..! 

3.  Did you try the same url directly in browser, to see any proxy path..  

Regards,

Venkat

former_member289261
Active Contributor
0 Kudos

Hi,

Remove "https://" from your host string.

i.e use "xxxx.aspx" instead of "https://xxxx.aspx"

As Export parameter "scheme" takes care of the protocol to be used http or https.

Regards,

Ashish Rawat

0 Kudos

Hi Asish,

Removed Https Still getting same error

Regards

Raghu

former_member289261
Active Contributor
0 Kudos

Hi,

there are some changes that your code needs :

1. First of all http://xxxx.aspx is an invalid address.

     a URL consists of 3 parts - "protocol used(http/https)" + domain("www.abc.com") + path      ("/xyz/pqr/")

     So your URL should be like - "https://www.abc.com/xxx.aspx".

2. In parameter HOST store domain. It will be like

     host = "www.abc.com"

3. Use integer instead of text literal for value of parameter SCHEME.

     i.e scheme = 2 instead of scheme = '2'.

4. After you set the request data , You need to set the path.

     Use

     cl_http_utility=>set_request_uri( request = client->request

                                                        uri  = uri ).

     where variable uri = "/xxx.aspx'       "uri contains path

5. After call of method http_client->sent( ) and http_client->recieve

     check for last error message using

     if sy-subrc <> 0.

      call method client->get_last_error

                                    importing code = subrc

                                    message = errortext.

6. At the end close the connection using

     call method client->close

                                    exceptions http_invalid_state = 1

                                    others = 2.

Hope following this resolves your issue.

Regards,

Ashish Rawat

0 Kudos

Hi Ashish,

Did changes  to my code as above. still same error

Regards

raghu

0 Kudos

Check if you are behind any proxy server and add the proxy settings if so.