Skip to Content
avatar image
Former Member

Export values for CL_HTTP_CLIENT=>CREATE

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    May 19, 2010 at 09:52 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

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

  • May 20, 2010 at 03:43 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded