2007 Jan 16 1:08 AM
I use function module HTTP_POST from ABAP to send a request to an external server via HTTPS URL. This works fine I get a response status back of 200 and the external server processed the request and I get a correct response in the body of the response.
When I try and replicate this using the newer method cl_http_client . I get a response status back of 200 but the external server can't process the request and doesn't return the expected body response.
The call to HTTP_POST which works is as below:
The only header request I have to create is Content-type:
All the others are created automatically by the function module
CALL FUNCTION 'HTTP_POST'
ABSOLUTE_URI = url
REQUEST_ENTITY_BODY_LENGTH = l_length
BLANKSTOCRLF = 'X'
IMPORTING
STATUS_CODE = l_status_code
STATUS_TEXT = l_status_text
RESPONSE_ENTITY_BODY_LENGTH = l_length_response
TABLES
REQUEST_ENTITY_BODY = GT_REQUEST_ENTITY_BODY
RESPONSE_ENTITY_BODY = GT_RESPONSE_ENTITY_BODY
RESPONSE_HEADERS = GT_RESPONSE_HEADERS
REQUEST_HEADERS = GT_REQUEST_HEADERS
When I try and replicate this call using cl_http_client
I disable the compress.
l_http_client->propertytype_accept_compress = l_http_client->co_disabled.
<b>How do I replicate the BLANKSTOCRLF = 'X' in the HTTP_POST function module?</b>
The headers that I have to create are now Content-type and Content-length.
when SAP creates the HTTP request it converts these to all lower case e.g. content-type and content-length. Is there anyway I can stop this from happening.
Thanks,
2007 Jan 16 5:22 AM
when using cl_http_client
call method cl_http_client=>create
exporting
host = 'www.webservicex.net'
service = '80'
scheme = '1'
proxy_host = wf_proxy
proxy_service = wf_port
importing
client = http_client.
the scheme has to be 2 to tell it that is https
and for setting content type and length the code would be something like below.
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.
Regards
Raja
2007 Jan 16 5:22 AM
when using cl_http_client
call method cl_http_client=>create
exporting
host = 'www.webservicex.net'
service = '80'
scheme = '1'
proxy_host = wf_proxy
proxy_service = wf_port
importing
client = http_client.
the scheme has to be 2 to tell it that is https
and for setting content type and length the code would be something like below.
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.
Regards
Raja