Skip to Content

Authentication error when using CL_HTTP_CLIENT

Hi all,

I'm using an instruction from the blog of Thomas Jung to get an image from the content server into the cache of the ICM framework. See this [blog Thomas Jung|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417200)ID0623211050DB12910368107152505592End?blog=/pub/wlg/1012].

See also this thread: [Approach content repository other way then URL approach|https://forums.sdn.sap.com/Approach content repository other way then URL approach]

At the point where I want to receive the response I currently get a popup where I'm asked to logon. Probably logon to the contentserver. I get this logon when the authentication on the content server is swithed on. Evwerything works fine when this authentication is switched off.

I want to know how I can set this authentication in my instance of CL_HTTP_CLIENT in order to make the receive of the image working fine.

Has anybody ever faced the same issue?

Regards,

Joost

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Oct 20, 2009 at 02:42 PM

    You have two choices.

    1. You can feed the authentication into the CL_HTTP_CLIENT instance using the authenticate method:

    call method cl_http_client=>create
        exporting
          host               = me->ls_login_info-url
          service            = me->c_http_service_port
          scheme             = cl_http_client=>schemetype_http
        importing
          client             = me->http_client
        exceptions
          argument_not_found = 1
          plugin_not_active  = 2
          internal_error     = 3
          others             = 4.
    
       me->http_client->propertytype_logon_popup = me->http_client->co_disabled.
        data l_username type string.
        data l_password type string.
        l_username = 'MyUser'
        l_password = 'MyPassword'.
        call method me->http_client->authenticate
          exporting
            username             = l_username
            password             = l_password.

    2. Second option is to use HTTP destinations from SM59. This is a bit more managable since the password is maintained in the SM59 configuration and encrypted for you.

    cl_http_client=>create_by_destination(
        exporting
          destination              = c_destination    " Logical destination (specified in function call)
        importing
          client                   = r_api->http_client  " HTTP Client Abstraction
        exceptions
          argument_not_found       = 1
          destination_not_found    = 2
          destination_no_authority = 3
          plugin_not_active        = 4
          internal_error           = 5
          others                   = 6 ).

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Thomas,

      Me problem is solved now. In constantly faced some "orgnizational hurdles" when trying to get credentials for creating an RFC (to put it delicately). But I found another way of creating the URL to the contentserver. Via the service sap/bc/contentserver/ I concatenate a URL as follows:

       CONCATENATE 'http://' sy-host 'domain:port/sap/bc/contentserver/' sy-mandt '?' 

      After that I finish the rest of the URL by concatenating the pointer to the document after the ? in the above URL.

      The I create the http_client as you described in your blog via the create_by_url, followed by all the other steps.

      To use the service "contentsever" in SICF as described above, you need to create an external alias in SICFwhere you specify the logon data based upon a systemuser.

      Thanks for thinking with me!

      Regards,

      Joost

      P.S. Enjoyed your session in Vienna about new WD4A functionality...very nice stuff coming up!!! Didn't talk to you anymore...maybe next time.