cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP post with custom headers to HTTPS URL?

Former Member
0 Kudos

Hello Experts,

My scenario is a webservice to sync HTTP POST. I need to populate custom HTTP headers and I will receive some values in HTTP header section. I'll need to read these header values and use for further processing.

How can I achieve this? the target URL is https and does not require any client cert.

Should I use AXIS SOAP adapter or plain HTTP adapter? Form some reason, I'm unable to create a successful HTTP port in SM59..which has made it difficult for me to use plain HTTP adapter. What other options do I have?

Please advise.

Thanks

Karthik

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

you can try to write abap program to test .

*Crete connection

url = 'http://your.url'.
cl_http_client=>create_by_url(
   EXPORTING
     url                = url
*    proxy_host         = 'proxyaddress'
*    proxy_service      = 'proxyip'
*    ssl_id             = ssl_id
*    sap_username       = sap_username
*    sap_client         = sap_client
   IMPORTING
     client             = lo_http_client
   EXCEPTIONS
     argument_not_found = 1
     plugin_not_active  = 2
     internal_error     = 3
     OTHERS             = 4
        ).
IF sy-subrc <> 0.
   MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

*Fill header data
CALL METHOD lo_http_client->request->set_header_field
   EXPORTING
     name  = 'Content-Type'
     value = 'multipart/form-data'.
CALL METHOD lo_http_client->request->set_header_field
   EXPORTING
     name  = '~request_method'
     value = 'POST'.

CALL METHOD lo_http_client->request->set_form_field
   EXPORTING
     name  = 'FORM_FIELD'
     value = '4'.

*Send request
CALL METHOD lo_http_client->send
   EXCEPTIONS
     http_communication_failure = 1
     http_invalid_state         = 2.

*Get return

CALL METHOD lo_http_client->receive
   EXCEPTIONS
     http_communication_failure = 1
     http_invalid_state         = 2
     http_processing_failed     = 3.

* DO something with return
DATA: http_status_code  TYPE i,
status_text  TYPE string.
CALL METHOD lo_http_client->response->get_status
   IMPORTING
     code   = http_status_code
     reason = status_text.
WRITE: / 'HTTP_STATUS_CODE = ',
http_status_code,
/ 'STATUS_TEXT = ',
status_text
.
DATA lv_result  TYPE string.

CALL METHOD lo_http_client->response->get_cdata
   RECEIVING
     data = lv_result.
WRITE:/ lv_result.

Former Member
0 Kudos

Hi,

By default HTTP will not allow to read Http Header so

You can go for SOAP Axis adapter where handlers will be available to read http headers..

HTH

Rajesh

markangelo_dihiansan
Active Contributor
0 Kudos

Hello Karthik,

Not sure if this is possible using standard means, I can  think of two approaches:

1. Java UDF to call this webservice and add your custom headers

2. Use a custom function module that uses the ABAP Class CL_HTTP_CLIENT to add the custom headers

Hope this helps,

Mark