09-02-2013 11:16 AM
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.
09-02-2013 9:15 PM
Ask your Basis guy if HTTPS service is enabled in your system.
You can achieve this at TCODE SMICM -> GoTo > Services.
09-03-2013 8:00 AM
09-03-2013 1:27 PM
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?
09-03-2013 2:19 PM
09-04-2013 7:14 AM
Hi John ,
Tried in Capital letter also.But error remains same. 'Communication Failure'.
09-04-2013 7:22 AM
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.
09-04-2013 7:28 AM
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
09-04-2013 12:18 PM
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
09-05-2013 5:04 AM
09-05-2013 7:46 AM
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
09-10-2013 9:21 AM
Hi Ashish,
Did changes to my code as above. still same error
Regards
raghu
09-11-2013 7:41 AM
Check if you are behind any proxy server and add the proxy settings if so.