Application Development and Automation 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: 
Read only

Method IF_HTTP_REQUEST->GET_HEADER_FIELD is not returning 'Authorization' header value

srinivas_cheruku
Explorer
0 Likes
3,352

Hi All,

I have added a class using interface IF_HTTP_EXTENSION and implemented the method IF_HTTP_EXTENSION~HANDLE_REQUEST as follows:

method IF_HTTP_EXTENSION~HANDLE_REQUEST.

     DATA:

         name TYPE STRING,

         value TYPE STRING.

    name = 'Authorization'.

*   name = 'Host'.

    value = server->request->GET_HEADER_FIELD( name ).

  if value is initial.

*        Authorization not found. Set Header WWW-Authenticate=Negotiate

*        and response code as 401.

      server->response->SET_STATUS( code = 401  reason = 'Authentication Required' ).

       server->response->SET_HEADER_FIELD( name = 'WWW-Authenticate' value = 'Basic' ).

      CALL METHOD server->response->set_cdata( data = 'Authenticate Header and Response Code set' ).

    else.

      CALL METHOD server->response->set_cdata( data = value ).

    endif.

endmethod.

The code above is trying to set the 401 response code with WWW-Authenticate header when the Authorization header is not found. This is working fine.

And, the Browser is able to send the Authorization header to the server (checked the http trace using HTTPWatch), but for some reason the method GET_HEADER_FIELD is not returning the Authorization header value.

Any ideas or suggestions on getting the Authorization header would be greatly appreciated.

Thanks in Advance,

Srini

3 REPLIES 3
Read only

Former Member
0 Likes
1,909

Hi Srini,

1. log on to SAP system with user XXX .

2. Do your steps to call webservice from your abap service home page - use the same user id for log on.

3. As soon as you see the error message as you mentioned

Run transaction SU53 in the target SAP system . This should tell you the authority object where the failure had happend.

or

Just Run your application in different browser then see is it run properly or not. Because some time the browser may no support

Hope this will helpful to you.

Warm Regards,

John.

Read only

0 Likes
1,909

I tried closing all browser instances and opening again and still the same issue. The issue is not at the browser as the http trace shows the browser is sending the Authorization header, but the ABAP code e.g. request->GET_HEADER_FIELD() on server is not able to get the value on NW 7.00 system as said in the other comment, but the same code works on NW 7.30 system.

Any idea why?

Read only

srinivas_cheruku
Explorer
0 Likes
1,909

Hi,

The code is not able to get the Authorization header value on SAP NW 7.00 SP13, where as the same code is working fine on SAP NW 7.30. Not sure why the code didn't work on 7.00. Any ideas?

Thanks,
Srini