Skip to Content
0
Jan 11, 2011 at 12:51 AM

Hidden Form fields in an HTTP POST

660 Views

Does anyone know how to pass hidden form fields into an HTTP Post? Here is an example in HTML. I need to do the same thing in ABAP:

<html>

<body>

https://www.aesdirect.gov/weblink/weblink.cgi" METHOD="POST">

<INPUT TYPE="HIDDEN" NAME="wl_app_ident" VALUE="TEST">

http://www.weblinktestapp.com/nologin.html">

http://www.weblinktestapp.com/nosed.html">

http://www.weblinktestapp.com/success.html">

<input type="submit" value="Submit">

</FORM>

</body>

</html>

Here is my code so far:

L_POST_URI = '/weblink/weblink.cgi'.

POST_HOST = 'www.aesdirect.gov'.

CALL METHOD cl_http_client=>create

EXPORTING

host = POST_HOST

service = '443'

scheme = '2'

ssl_id = 'ANONYM'

  • proxy_host = wf_proxy

  • proxy_service = wf_port

IMPORTING

client = http_client.

http_client->propertytype_logon_popup = http_client->co_disabled.

wf_user = '' .

wf_password = '' .

  • proxy server authentication

CALL METHOD http_client->authenticate

EXPORTING

proxy_authentication = 'X'

username = wf_user

password = wf_password.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_method'

value = 'POST'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_protocol'

value = 'HTTPS/1.0'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'HOST'

value = POST_HOST.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = '~request_uri'

value = L_POST_URI.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Type'

value = 'text/xml; charset=utf-8'.

CALL METHOD http_client->request->set_header_field

EXPORTING

name = 'Content-Length'

value = txlen.

*CALL METHOD http_client->request->set_header_field

data: lt_formfields type TIHTTPNVP.

data: ls_formfields type IHTTPNVP.

ls_formfields-name = 'wl_app_ident'.

ls_formfields-value = 'TEST'.

append ls_formfields to lt_formfields.

*ls_formfields-name = 'wl_app_name'.

*ls_formfields-value = 'TEST'.

*append ls_formfields to lt_formfields.

ls_formfields-name = 'wl_nosed_url'.

ls_formfields-value = 'http://www.weblinktestapp.com/nosed.html'.

append ls_formfields to lt_formfields.

ls_formfields-name = 'wl_success_url'.

ls_formfields-value = 'http://www.weblinktestapp.com/success.html'.

append ls_formfields to lt_formfields.

CALL METHOD http_client->request->set_form_fields

EXPORTING

FIELDS = lt_formfields.

CALL METHOD http_client->request->set_cdata

EXPORTING

data = wf_string

offset = 0

length = rlength.

CALL METHOD http_client->send

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2.

CALL METHOD http_client->receive

EXCEPTIONS

http_communication_failure = 1

http_invalid_state = 2

http_processing_failed = 3.

CLEAR wf_string1 .

wf_string1 = http_client->response->get_cdata( ).

thank you,