2006 Oct 18 12:46 PM
Hi,
I want to use the FM HTTP_POST to call an external program. That works fine as long as I do not use the tables REQUEST_ENTITY_BODY and REQUEST_HEADERS.
I must send data to the external program and I want to do this with an XML file.
I send the XML file with the REQUEST_ENTITY_BODY table. But I dont know what to write in the REQUEST_HEADERS table. I tried it with: 'Content-Type:TEXT/XML; charset=utf-8' but that doesnt work.
I get the error message in the response_headers table:
X-errorDescription: Error on line 1 of document : Dokumentwurzelelement fehlt Nested exception: Dokumentwurzelelement fehlt
Do anybody know what the REQUEST_HEADERS table should contain?
I cannot use the CL_HTTP_CLIENT class because of the release 4.6 C.
Thanks.
Kind Regards,
Michael Schöffer
2006 Oct 29 10:16 AM
welcome to SDN.
if you use request_entity_body you also need to pass the size of the body
request_entity_body_length = size
i guess the request header you are passing is ok.
Regards
Raja
2009 Jul 01 8:23 PM
Hi Raja,
Do you have any sample ABAP code which shows how to pass an XML Request correctly via HTTP_POST ?
Thanks,
Chris
2009 Jul 01 8:21 PM
2009 Oct 30 3:22 PM
It's been very long since you had posted this topic. Were you able to resolve this issue? Could you post the details?
Raj
2014 Jul 15 6:17 AM
I resolve this issue.
DATA: LT_REQUEST_HEADER TYPE TABLE OF SBCHEADER WITH HEADER LINE,
LT_REQUEST_BODY TYPE TABLE OF SBCBODY WITH HEADER LINE,
LT_RESPONSE_HEADER TYPE TABLE OF SBCHEADER WITH HEADER LINE,
LT_RESPONSE_BODY TYPE TABLE OF SBCBODY WITH HEADER LINE.
APPEND 'Content-Type: text/xml; charset=UTF-8' TO LT_REQUEST_HEADER.
APPEND '<?xml version="1.0" encoding="euc-kr"?>' TO LT_REQUEST_BODY.
APPEND '<root> ' TO LT_REQUEST_BODY.
APPEND '<params> ' TO LT_REQUEST_BODY.
* (...blablabla...xml data string...)
* just call
CALL FUNCTION 'HTTP_POST'
EXPORTING
ABSOLUTE_URI = URI " url...
REQUEST_ENTITY_BODY_LENGTH = LV_LEN " blank variable.
RFC_DESTINATION = 'SAPHTTP'
* PROXY =
* PROXY_USER =
* PROXY_PASSWORD =
* USER =
* PASSWORD =
BLANKSTOCRLF = 'X'
IMPORTING
STATUS_CODE = STATUS_CODE
STATUS_TEXT = STATUS_TEXT
RESPONSE_ENTITY_BODY_LENGTH = LV_LEN
TABLES
REQUEST_ENTITY_BODY = LT_REQUEST_BODY
RESPONSE_ENTITY_BODY = LT_RESPONSE_BODY
RESPONSE_HEADERS = LT_RESPONSE_HEADER
REQUEST_HEADERS = LT_REQUEST_HEADER.
WRITE / 'THE HEADER DATA '.
LOOP AT LT_RESPONSE_HEADER.
WRITE:/ LT_RESPONSE_HEADER.
ENDLOOP.
WRITE:/ 'THE BODY DATA : ' .
LOOP AT LT_RESPONSE_BODY.
WRITE:/ LT_RESPONSE_BODY.
ENDLOOP.
When test program, use http monitoring tool(HTTP Analyzer...and so on...) and check http packit header.
2014 Aug 22 3:41 PM
Chan-Seok Jeon, do you have examples of structures/syntax for the parameters that you append to LT_REQUEST_BODY? I have been searching for this information and cannot find it anywhere. I have a web service that i need to pass parameters and nothing i do is working. Any examples would help, as i cannot find anything for this. i assumed that i would just send the xml data, but that is not working. i continue to get errors.
thanks,
Erik Thiessen
2014 Aug 25 2:03 AM
This is my full source~
*----------------------------------------------------------------------*
* Report ZEONC_HTTP_POST
*
*----------------------------------------------------------------------*
*
*
*----------------------------------------------------------------------*
REPORT ZEONC_HTTP_POST.
PARAMETERS : P_URI(100) LOWER CASE DEFAULT
'http://xxx.com/dwgNew/Mi_cutDwgDown.jsp'.
* HTTP POST
DATA : LV_STATUS_CODE(5),
LV_STATUS_TEXT(300),
LV_LEN TYPE I,
LV_PARAMS TYPE STRING,
LT_REQ_HEAD TYPE TABLE OF SBCHEADER WITH HEADER LINE,
LT_REQ_BODY TYPE TABLE OF SBCBODY WITH HEADER LINE,
LT_RES_HEAD TYPE TABLE OF SBCHEADER WITH HEADER LINE,
LT_RES_BODY TYPE TABLE OF SBCBODY WITH HEADER LINE.
* XML Parsing
DATA : LV_XML TYPE STRING,
LO_NODE TYPE REF TO IF_IXML_NODE,
LV_VALUE TYPE STRING,
LO_XML_DOC TYPE REF TO CL_XML_DOCUMENT.
* ETC.
DATA : LV_URL TYPE BXMNODES-URL.
* Set Header
APPEND 'Content-Type: text/xml; charset=euc-kr' TO LT_REQ_HEAD.
* Set Parameter
APPEND '<?xml version="1.0" encoding="euc-kr"?> ' TO LT_REQ_BODY.
APPEND '<root> ' TO LT_REQ_BODY.
APPEND '<params> ' TO LT_REQ_BODY.
APPEND '<param id="admMode" type="STRING">Y</param> ' TO LT_REQ_BODY.
APPEND '<param id="block" type="STRING">A23</param> ' TO LT_REQ_BODY.
APPEND '<param id="gubun" type="STRING">lot</param> ' TO LT_REQ_BODY.
APPEND '<param id="ocomp" type="STRING"></param> ' TO LT_REQ_BODY.
APPEND '<param id="path" type="STRING"></param> ' TO LT_REQ_BODY.
APPEND '<param id="shipno" type="STRING">S630</param> ' TO LT_REQ_BODY.
APPEND '<param id="userid" type="STRING">AAAAAAAAAA</param> ' TO LT_REQ_BODY.
APPEND '<param id="plate" type="STRING">Y</param> ' TO LT_REQ_BODY.
APPEND '<param id="print_view" type="STRING">V</param> ' TO LT_REQ_BODY.
APPEND '</params> ' TO LT_REQ_BODY.
APPEND '<dataset id="ds_input"> ' TO LT_REQ_BODY.
APPEND '<colinfo id="chk" size="1" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="dwgno" size="2" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="fab" size="3" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="filechk" size="3" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="filename" size="30" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="grp" size="1" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="lot" size="3" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="revno" size="3" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<colinfo id="ship" size="5" type="STRING"/> ' TO LT_REQ_BODY.
APPEND '<record> ' TO LT_REQ_BODY.
APPEND '<chk>1</chk> ' TO LT_REQ_BODY.
APPEND '<dwgno>01</dwgno> ' TO LT_REQ_BODY.
APPEND '<fab>COM</fab> ' TO LT_REQ_BODY.
APPEND '<filechk>Oilechk> ' TO LT_REQ_BODY.
APPEND '<filename>XXXXXXXXXXXXX.XXX</filename> ' TO LT_REQ_BODY.
APPEND '<grp>4L</grp> ' TO LT_REQ_BODY.
APPEND '<lot>A23</lot> ' TO LT_REQ_BODY.
APPEND '<revno>0</revno> ' TO LT_REQ_BODY.
APPEND '<ship>S630</ship> ' TO LT_REQ_BODY.
APPEND '</record> ' TO LT_REQ_BODY.
APPEND '</dataset> ' TO LT_REQ_BODY.
APPEND '</root> ' TO LT_REQ_BODY.
* Send Post **********************************************************
CALL FUNCTION 'HTTP_POST'
EXPORTING
ABSOLUTE_URI = P_URI
REQUEST_ENTITY_BODY_LENGTH = LV_LEN
RFC_DESTINATION = 'SAPHTTP'
* PROXY =
* PROXY_USER =
* PROXY_PASSWORD =
* USER =
* PASSWORD =
BLANKSTOCRLF = 'X'
IMPORTING
STATUS_CODE = LV_STATUS_CODE
STATUS_TEXT = LV_STATUS_TEXT
RESPONSE_ENTITY_BODY_LENGTH = LV_LEN
TABLES
REQUEST_ENTITY_BODY = LT_REQ_BODY
RESPONSE_ENTITY_BODY = LT_RES_BODY
RESPONSE_HEADERS = LT_RES_HEAD
REQUEST_HEADERS = LT_REQ_HEAD
EXCEPTIONS
CONNECT_FAILED = 1
TIMEOUT = 2
INTERNAL_ERROR = 3
TCPIP_ERROR = 4
SYSTEM_FAILURE = 5
COMMUNICATION_FAILURE = 6
OTHERS = 7.
* Check result
IF LV_STATUS_CODE NE '200'. " Failure
WRITE : / 'STATUS CODE :' , 15 LV_STATUS_CODE.
WRITE : / 'STATUS TEXT :' , 15 LV_STATUS_TEXT , /.
WRITE : / 'RESPONSE HEADER : '.
LOOP AT LT_RES_HEAD.
WRITE /3 LT_RES_HEAD.
ENDLOOP.
WRITE : /, / 'RESPONSE BODY : '.
LOOP AT LT_RES_BODY.
WRITE /3 LT_RES_BODY.
ENDLOOP.
EXIT.
ENDIF.
* Parsing XML Return Value
CLEAR : LV_XML.
LOOP AT LT_RES_BODY.
CONCATENATE LV_XML LT_RES_BODY INTO LV_XML.
ENDLOOP.
CREATE OBJECT LO_XML_DOC.
LO_XML_DOC->PARSE_STRING( STREAM = LV_XML ).
LO_NODE = LO_XML_DOC->FIND_NODE( NAME = 'iis_url' ).
LV_VALUE = LO_XML_DOC->GET_NODE_VALUE( NODE = LO_NODE ).
LV_URL = LV_VALUE.
CALL FUNCTION 'PRGN_GENER_EXECUTE_URL'
EXPORTING
NODE_DATA = LV_URL.
2014 Aug 26 6:26 PM
Thank you very much. This is now working correctly. I would like to give you points but i am not allowed in the thread as it is already answered. but if it means anything, THANKS!!!! I do appreciate it.