Skip to Content

Calling https:// url from ABAP code IF_HTTP_CLIENT

Hi,

Is call to https:// type URLs possible through ABAP code?

Can IF_HTTP_CLIENT be used in this case?

If no, what are the alternatives?

Please help.

Thanks and regards,

Amey

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Dec 24, 2010 at 08:18 AM

    Resolved myself.

    "STEP-1 : CREATE HTTP CLIENT
    CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
        EXPORTING
          URL                = WL_URL
        IMPORTING
          CLIENT             = W_HTTP_CLIENT
        EXCEPTIONS
          ARGUMENT_NOT_FOUND = 1
          PLUGIN_NOT_ACTIVE  = 2
          INTERNAL_ERROR     = 3
          OTHERS             = 4
          .
    
      DATA: EMPTYBUFFER TYPE XSTRING.
    
          EMPTYBUFFER = ''.
      CALL METHOD W_HTTP_CLIENT->REQUEST->SET_DATA
            EXPORTING DATA = EMPTYBUFFER.
    
    "STEP-2 :  AUTHENTICATE HTTP CLIENT
    CALL METHOD W_HTTP_CLIENT->AUTHENTICATE
      EXPORTING
        USERNAME             = 'user'
        PASSWORD             = 'password'
        "LANGUAGE             = SY-LANGU
        .
    
    CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
         EXPORTING NAME  = '~request_method'
                   VALUE = 'GET'
                    .
    
     CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING NAME  = 'Content-Type'
                    VALUE = 'text/xml; charset=utf-8'.
    
     CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING NAME  = 'Accept'
                    VALUE = 'text/xml, text/html'.
    
     CONCATENATE WL_URL '#' INTO SOAP_ACTION.
     CALL METHOD W_HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING NAME  = 'SOAPAction'
                    VALUE = SOAP_ACTION.
    
    "STEP-3 :  SEND HTTP REQUEST
      CALL METHOD W_HTTP_CLIENT->SEND
        EXCEPTIONS
          HTTP_COMMUNICATION_FAILURE = 1
          HTTP_INVALID_STATE         = 2.
    
    *-----------------------------------------------------------------
    
    "STEP-4 :  GET HTTP RESPONSE
        CALL METHOD W_HTTP_CLIENT->RECEIVE
          EXCEPTIONS
            HTTP_COMMUNICATION_FAILURE = 1
            HTTP_INVALID_STATE         = 2
            HTTP_PROCESSING_FAILED     = 3.
    
    "STEP-5 : Read HTTP RETURN CODE
    CALL METHOD W_HTTP_CLIENT->RESPONSE->GET_STATUS
        IMPORTING
          CODE = HTTP_STATUS_CODE
          REASON = STATUS_TEXT
          .
      WRITE: / 'HTTP_STATUS_CODE = ',
              HTTP_STATUS_CODE,
             / 'STATUS_TEXT = ',
             STATUS_TEXT
             .
    
    "STEP-6 :  READ RESPONSE DATA
     CALL METHOD W_HTTP_CLIENT->RESPONSE->GET_CDATA
            RECEIVING DATA = W_RESULT .
    
    

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Amey,

      I have a requirement to send an XML file from SAP to Third party URL starts with HTTPS://.

      I would like to know, how can i achieve this task. Is your code will work for me also?

      If yes please share the complete code. Also let me know is there any basis settings required for this task.

      It is very urgent.. Thanks in Advance.

      Regards,

      Namdev

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2011 at 11:03 AM

    Hi,

    I have a requirement to send XML data from ECC to 3rd party URL which starts with HTTPS://.

    Can any body tell me " How to achieve this ".

    Please share me the information regarding this.

    Thanks in advance.

    Regards,

    Namdev

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.