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: 

Export values for CL_HTTP_CLIENT=>CREATE

Former Member
0 Kudos

Hi All,

I am trying to use methos create of Class CL_HTTP_CLIENT

CALL METHOD CL_HTTP_CLIENT=>CREATE

EXPORTING

HOST = host "e.g. www.google.co.uk

SERVICE = port

PROXY_HOST = proxy_host

PROXY_SERVICE = proxy_port

SCHEME = scheme

IMPORTING

CLIENT = client

EXCEPTIONS

ARGUMENT_NOT_FOUND = 1

PLUGIN_NOT_ACTIVE = 2

INTERNAL_ERROR = 3

others = 4.

My concern is how do we get 'PORT' value.

Also what value will go to proxy_host and proxy_port.

Is it value that is configured to internet connection for explorer ? How to get it?

Kindly site one example if possible. I have searched a lot on SDN bt m still not clear about the values and how to get them.

Regards,

Sangvir Singh

1 ACCEPTED SOLUTION

martin_voros
Active Contributor
0 Kudos

Hi,

firstly, the parameters SERVICE, PROXY_HOST and PROXY_SERVICE are optional so maybe you don't need to use them. The web server can listen on various port but usually it is port 80 (or 443 in case of SSL). So in case you connect to standard web site then you don't need to set this parameter. You also probably don't need to use proxy as well. So you don't need to set these fields as well.

Cheers

9 REPLIES 9

martin_voros
Active Contributor
0 Kudos

Hi,

firstly, the parameters SERVICE, PROXY_HOST and PROXY_SERVICE are optional so maybe you don't need to use them. The web server can listen on various port but usually it is port 80 (or 443 in case of SSL). So in case you connect to standard web site then you don't need to set this parameter. You also probably don't need to use proxy as well. So you don't need to set these fields as well.

Cheers

0 Kudos

Hi Martin,

Thanks for quick reply. i tried without using proxy and without using service, however i am getting error HTTP_COMMUNICATION_FAILURE.

Is there any pre-requisite to use this method.

We are on ECC 6.

Regards,

Sangvir Singh

0 Kudos

No pre-requisites but you should check transaction SMICM and make sure the service(s) are running on your app server (Goto -> Services) . HTTPS is not enabled by default, so if you're trying to use SSL, you'll need to configure some system parameters for it. Also, I think you'll find it easier to use method CREATE_BY_DESTINATION. You can set up the HTTP destination in SM59 and test it from there. Then your code simply needs to reference the destination name to create the client object. There are several blogs on SDN that show how to do this.

As far as determining the communication error, you can view the trace logs in SMICM and sometimes get more information from those as to the specific issue.

0 Kudos

Hi,

I doubt that the HTTP service needs to run in SMICM to connect using HTTP client. It has to be active if you run some services over http such as web dynpro applications. But I am not sure.

But it looks like method CREATE does not use URL but it uses logical destinations. I guess that you need to use method CREATE_BY_URL.

Cheers

0 Kudos

No, actually it does. You can't send an HTTP request without the active service. SAP will throw an ICM connection exception.

To the poster, why don't you trace the communication and try to get more information as I suggested or discuss the issue with your network team? You would not use the same values for the proxy server identification, if indeed one is necessary. The proxy info in Jerry's example is for a proxy on his side, not on Paypal's.

JerryWang
Advisor
Advisor
0 Kudos

Hello friend,

please refer to this example

data https_client type REF TO IF_HTTP_CLIENT.
data error_code type sysubrc.
data res_error type string.
DATA: res_data TYPE XSTRING,
      filename type string,
      path type string,
      fullPath type string.
DATA: WF_USER TYPE STRING .
data long_string type string.
DATA: WF_PASSWORD TYPE STRING .
TYPES line_x(512) TYPE x.
DATA lt_xstring TYPE TABLE OF line_x.
  DATA l_length TYPE i.

CALL METHOD CL_HTTP_CLIENT=>CREATE
  EXPORTING
    HOST          = 'www.paypal.com'
    SERVICE       = '443'
    SCHEME        = '2'
   PROXY_HOST    = '10.56.192.26'
   PROXY_SERVICE = '8080'
  IMPORTING
    CLIENT        = HTTPs_CLIENT.
check https_client is not initial.
*HTTPs_CLIENT->PROPERTYTYPE_LOGON_POPUP = HTTPs_CLIENT->CO_DISABLED.


* proxy server authentication

*CALL METHOD HTTPs_CLIENT->AUTHENTICATE
*  EXPORTING
*    PROXY_AUTHENTICATION = 'X'
*    USERNAME             = WF_USER
*    PASSWORD             = WF_PASSWORD.


CALL METHOD HTTPs_CLIENT->REQUEST->SET_HEADER_FIELD
  EXPORTING
    NAME  = '~request_method'
    VALUE = 'POST'.


CALL METHOD HTTPs_CLIENT->REQUEST->SET_HEADER_FIELD
  EXPORTING
    NAME  = '~request_uri'
    VALUE = '/cn/cgi-bin/webscr?dispatch=5885d80a13c0db1ffc45dc241d84e953d0e88f8d71535079b246201019c8adab'.

CALL METHOD HTTPs_CLIENT->SEND
  EXCEPTIONS
    HTTP_COMMUNICATION_FAILURE = 1
    HTTP_INVALID_STATE         = 2.
if sy-subrc <> 0.
  CALL METHOD https_client->get_last_error
    IMPORTING
      code = error_code.
  case error_code.
    when 1.
      write 'The communication is failed'.
    when 2.
      write 'invalid state of http'.
  endcase.
endif.

CALL METHOD HTTPs_CLIENT->RECEIVE
  EXCEPTIONS
    HTTP_COMMUNICATION_FAILURE = 1
    HTTP_INVALID_STATE         = 2
    HTTP_PROCESSING_FAILED     = 3.

Former Member
0 Kudos

Hi Jerry,

Thank you for the code provided.

I used the sample code with exactly same values ( PROXY_HOST = '10.56.192.26' PROXY_SERVICE = '8080' , let me know if i have to change them )

however, after running

CALL METHOD HTTPs_CLIENT->RECEIVE

EXCEPTIONS

HTTP_COMMUNICATION_FAILURE = 1

HTTP_INVALID_STATE = 2

HTTP_PROCESSING_FAILED = 3.

i am getting sy-subrc = 1 and hence the exception , HTTP_COMMUNICATION_FAILURE.

Kindly let me know what could be missing on our server to establish a connection.

Regards,

Sangvir

0 Kudos

Hello Sangvir,

Would you please first check whether '10.56.192.26' is avaible from your side? In your window system, click Start->Run->CMD, and ping 10.56.192.26, please check wether it works or not.

Unfortunately I am not familiar with system configuration topic, I go to SM59 in my system,Extras->HTTP Proxy Configuration.

In the first tab "Global settings" I see both "Proxy setting is Active" and "No proxy settings for local server" is enabled, in the second tab "HTTP log" I see "Host name" is maintained as 10.56.192.26 and port as 8080. Maybe you can try the same settings in your own system like mine and have a try?

Best Regards,

Jerry

Former Member
0 Kudos

HI Sangvir Singh,

Have you found solution to your problöem, I am facing the same problem.

Please let me know if you have solved it.

Thanks and regards,

NarsiReddy.