2008 Apr 30 11:50 PM
Hi,
Can anyone provide me some sample code of how to successfully get a list of cookies from a HTTP POST and send a list of cookies to an HTTP get. My code below does not seem to work. I know the URL I am posting to returns some cookies and the subsequent HTTP GET requires these cookies. I really don't need to know the names or the values of the cookies, I just need to be able to send them via the HTTP GET:
Code Example
data: client type ref to if_http_client,
xml_string type string,
xml_response type ref to cl_xml_document,
zsubrc type sy-subrc.
data: cookies type TIHTTPCKI.
cl_http_client=>create_by_url( exporting url = url importing client = client exceptions others = 1 ).
CLIENT->PROPERTYTYPE_ACCEPT_COOKIE = 1.
client->request->set_header_field( exporting name = '~request_method' value = 'POST' ).
client->request->set_header_field( exporting name = '~server_protocol' value = 'HTTP/1.1' ).
client->request->set_header_field( exporting name = 'Content-Type' value = 'text/xml' ).
client->request->set_data( exporting data = xml_xstring_in offset = 0 ).
client->send( exceptions http_communication_failure = 1 http_invalid_state = 2 ).
CLIENT->request->RECEIVE_COOKIE.
client->receive( exceptions http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 ).
client->request->GET_COOKIES( changing cookies = cookies ).
xml_xstring_out = client->response->get_data( ).
client->close( ).
Hi,
Can anyone provide me some sample code of how to successfully get a list of cookies from a HTTP POST and send a list of cookies to an HTTP get. My code below does not seem to work. I know the URL I am posting to returns some cookies and the subsequent HTTP GET requires these cookies. I really don't need to know the names or the values of the cookies, I just need to be able to send them via the HTTP GET:
Code Example
data: client type ref to if_http_client,
xml_string type string,
xml_response type ref to cl_xml_document,
zsubrc type sy-subrc.
data: cookies type TIHTTPCKI.
cl_http_client=>create_by_url( exporting url = url importing client = client exceptions others = 1 ).
CLIENT->PROPERTYTYPE_ACCEPT_COOKIE = 1.
client->request->set_header_field( exporting name = '~request_method' value = 'POST' ).
client->request->set_header_field( exporting name = '~server_protocol' value = 'HTTP/1.1' ).
client->request->set_header_field( exporting name = 'Content-Type' value = 'text/xml' ).
client->request->set_data( exporting data = xml_xstring_in offset = 0 ).
client->send( exceptions http_communication_failure = 1 http_invalid_state = 2 ).
CLIENT->request->RECEIVE_COOKIE.
client->receive( exceptions http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 ).
client->request->GET_COOKIES( changing cookies = cookies ).
xml_xstring_out = client->response->get_data( ).
client->close( ).
2008 Aug 28 7:21 PM
Hi Peter,
have you found an example? I'm trying to do the same, but have not found anything useful.
Thanks!
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |