XMLhttp.Send(xmlDoc) fails with error "Invalid at top level of document"

AronChanAronChan Member Posts: 9
Im trying to send a xml file through http to a webservice.

Ive tested the webservice with SOAPUI and it works as intended with the same xml file as im trying to send with nav.

this is the code that im executing:

XmlDoc := XmlDoc;

IF ISCLEAR(XMLhttp) THEN //'Microsoft XML, v6.0'.XMLHTTP60
CREATE(XMLhttp, FALSE, TRUE);
IF ISCLEAR(XmlDoc) THEN BEGIN//'Microsoft XML, v6.0'.DOMDocument
CREATE(XmlDoc,FALSE,TRUE);
XmlDoc.loadXML(CreateSMS);
END;

XMLhttp.open('POST', 'Webservice adress', FALSE);
XMLhttp.setRequestHeader('Content-Type: ', 'Content-Type: text/xml');
XMLhttp.send(XmlDoc);

IF XMLhttp.status = 200 THEN BEGIN
IF (XMLhttp.responseText <> '') THEN BEGIN
END;
END ELSE BEGIN
ERROR('Status %1 %2',XMLhttp.status,XMLhttp.statusText);
END;

CLEAR(XmlDoc);
CLEAR(XMLhttp);

When debugging i can see that it fails at the line XMLhttp.send(XmlDoc); with the error message "Invalid at the top level of document" (translated from danish so it might be a bit different)

When using the SOUPUI to test the service i get the following response:

<response>
<stat>
<sendtime>17-03-2016 10:19:59</sendtime>
<buffered>1</buffered>
<received>0</received>
<rejected>0</rejected>
</stat>
<details>
<sendtime>17-03-2016 10:19:59</sendtime>
<batchid>46413721</batchid>
<state>DONE</state>
</details>
<status>201</status>
</response>

Can anybody give me directions as how to solve this issue?

Best Answer

Answers

Sign In or Register to comment.