0

I am using dojo.request.xhr to make a post reqeust to geoserver. But the problem is when i'm using XMLHttpRequest to make the post request , it is working fine on the other hand when i'm using dojo.reqeust.xhr for the same thing its giving the following error.

*

org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not i (position: START_DOCUMENT seen i... @1:1) only whitespace content allowed before start tag and not i (position: START_DOCUMENT seen i... @1:1)

    *

dojo.request.xhr code -

xhr(url, {
            handleAs : "xml",
            data : postData,
            method : "POST",
            headers : {
                'Content-Type' : 'text/xml',
            },
        }).then(function(data){
            console.log(data);
        }, function(err){
            console.log("Error : " + err);
        }); 

above code is not working and giving the above mentioned error.

This is same post request using the XMLHttpRequest :-

var req = new XMLHttpRequest();
req.open("POST", url, true);
req.setRequestHeader('Content-type', 'text/xml');
req.onreadystatechange = function () {
    if (req.readyState != 4) return;
    if (req.status != 200 && req.status != 304) {
            alert("Error");
            return;
     }
     var xml = req.responseXML;
     console.log(xml);
 }
     if (req.readyState == 4) return;
 req.send(postData);

To check the XML(that i'm sending as postData) whether it is valid or not i used GeoServer's demo request tool to build the WFS request and its working fine.

UPDATE :- This is the link of XML file that i'm sending as a postData.

post_XML_File

Can anyone have any idea what i'm doing wrong?? Thanks in advance.

Neelesh
  • 666
  • 6
  • 17
  • can you post the XML? The error definitely points to XML not being properly formatted. you can check whether the XML gets parsed correctly over [here](http://www.xmlvalidation.com/) – frank Jul 03 '15 at 14:33
  • but same XML is working with XMLHttpRequest and also i also used the same xml file in Geoserver's wfs demo request builder it is working fine. – Neelesh Jul 03 '15 at 15:50
  • can you check the following [link](http://stackoverflow.com/questions/12430136/ksoap2-org-xmlpull-v1-xmlpullparserexception-expected-start-tag-error), which might help. – frank Jul 03 '15 at 16:10

0 Answers0