‎2006 Oct 18 6:58 AM
Hi all again,
I am setting content-type in the header to "text/xml" yet when I do a POST sap sends as content-type
"application/x-www-form-urlencoded". Is there something else I need to set to make it post with text/xml ?
cl_http_client=>create_by_url( EXPORTING url = url
ssl_id = 'ANONYM'
IMPORTING client = http_client ).
* create HTTP client object
* cl_http_client=>create_by_destination( EXPORTING DESTINATION = 'ZTOLLREQUEST'
* IMPORTING client = http_client ).
* Set HTTP headers
http_client->request->set_header_field( name = '~request_method'
value = 'POST' ).
http_client->request->set_header_field( name = 'Content-Type'
value = 'text/xml' ).
* http_client->request->set_header_field( name = 'Authorization'
* value = auth_string ).
* http_client->request->set_header_field( name = 'sap-password'
* value = 'ymous' ).
* Set payload
http_client->request->set_cdata( xml_string ).
* send and receive
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.regards
Allan
‎2006 Oct 18 7:18 AM
Hi Allan,
How did you find that SAP sends as "application/x-ww...
here is what i use along with encoding and never had any problem
call method http_client->request->set_header_field
exporting
name = 'Content-Type'
value = 'text/xml; charset=utf-8'.Regards
Raja
‎2006 Oct 18 7:18 AM
Hi Allan,
How did you find that SAP sends as "application/x-ww...
here is what i use along with encoding and never had any problem
call method http_client->request->set_header_field
exporting
name = 'Content-Type'
value = 'text/xml; charset=utf-8'.Regards
Raja
‎2006 Oct 18 7:35 AM
Hi Raja,
thank you again
The response I am getting from the (other companies) server is
Invalid MediaType in ContentType, expected text/xml but got application/x-www-form-urlencoded
I don't know any easy way of checking the outgoing headers to see if this is true.
I have tried your code snipet with the charset and I still get the same result.
Regards
Allan
‎2006 Oct 18 7:43 AM
i havent tried this (setting content type) when using create by url . may be try just the create method and then set the remaining part of the url as headers ~request_uri parameter. something like below.
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.
http_client->propertytype_logon_popup = http_client->co_disabled.
wf_user = user .
wf_password = password .
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 = '~server_protocol'
value = 'HTTP/1.1'.
call method http_client->request->set_header_field
exporting
name = '~request_uri'
value = '/airport.asmx'.
Regards
Raja
‎2006 Oct 19 3:37 AM
Thanks Raja,
It didn't work. As best as I can figure it it seems that http_client->request->set_header_field only allows certain fields to be set or they are overwritten at send time.
For example ~request_uri and Content-Type seemed to be ignored while ~request_method does seem to work.
It would be nice if there was some documentation for this
Thanks & regards
Allan
‎2006 Oct 19 3:39 AM
hi again,
I should mention the system is Netweaver 04, in case that makes a difference.
Allan