‎2007 Jan 19 3:25 PM
Hi Experts,
I am trying to fill & submit an http form through abap using CL_HTTP_CLIENT class methods "request". here is my code:-
DATA: client TYPE REF TO if_http_client.
Create Client-Object
CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
EXPORTING
url = url_string
IMPORTING
CLIENT = client
EXCEPTIONS
ARGUMENT_NOT_FOUND = 1
PLUGIN_NOT_ACTIVE = 2
INTERNAL_ERROR = 3
others = 4.
IF sy-subrc <> 0.
WRITE: / 'Client Object could not be created. SUBRC=', sy-subrc.
EXIT.
ENDIF.
Set Header Field of request
CALL METHOD client->request->if_http_entity~set_header_field
EXPORTING
name = '~request_enctype'
value = 'multipart/form-data'.
CALL METHOD client->request->if_http_entity~set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
try posting form fields
CALL METHOD client->request->if_http_entity~set_form_field
EXPORTING
name = 'datasource'
value = 'GSAPO'.
CALL METHOD client->request->if_http_entity~set_form_field
EXPORTING
name = 'feedtype'
value = 'full'.
CALL METHOD client->request->if_http_entity~set_form_field
EXPORTING
name = 'data'
value = xml_string.
CALL METHOD client->send
EXPORTING
TIMEOUT = CLIENT->CO_TIMEOUT_INFINITE
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5
.
IF sy-subrc <> 0.
WRITE: / 'Request could not be sent - communication error. SUBRC=',
sy-subrc.
EXIT.
ENDIF.
Receive Response
CALL METHOD client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE: 'Response not obtained - communication error SUBRC = ' ,
sy-subrc.
EXIT.
ENDIF.
Close HTTP connection
CALL METHOD client->close
EXCEPTIONS
http_invalid_state = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE 'HTTP connection in undefined state'.
EXIT.
ENDIF.
*End of code.
The problem here is I am getting exception "http_connection_failed" in recieve method.
Can any body help me out.
Thanks in advance.
Madhu.
‎2007 Jan 21 9:14 AM
is the http destination within intranet or internet? do you connect to internet via proxy server?
Raja