Having a problem that I cannot seem to get over. Simply trying to do a post of an xml string to a web site. Seems to work fine, until I hit a certain size of the string, then it fails. I have searched for other methods, but am coming up blank. Here is the code that I am trying to run:

%>
 
	var objHTTP, strResult;
	objHTTP = new XMLHttpRequest();
	objHTTP.open('POST',<%=rtn_url%>,false);
	objHTTP.setRequestHeader('Content-Type','text/xml');


	objHTTP.send('oracleCart=' + <%=xmlString%>); 

<%

the string <%=xmlString%> is a properly formatted XML string. I have dumped it's value and checked it. This is for a shopping cart. If I add over 10 items, I get errors saying that the xml format is not correct. Any help on this would be appreciated.

Thanks,
Mic

To expand on this, here is the message that I recieve when I run the code to do the post:

Cannot have a DOCTYPE declaration outside of a prolog. Error processing resource 'https://www.americantexchem.com:9443/stor...

<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.1.007/cXML.dtd">
----------^

I have goodled this, but not seeing any instance that is similar to this. If I remove elements from the xml string, it does post fine. Not really sure what I am missing here. Thanks for any help.

Is your data properly encoded in XML safely? I would do a check by taking the XML document you're posting, keeping all the nodes intact, but replace all the data with simple like text. For example, replace every text node and attribute value to xxxxxxx.

Try submitting that. Also, it could be possible that your XML post is being too restrictive for your web server to handle. You could change that.

Is there a way you could post the XML doc here so we can see?

I actually went a different direction on the post with the following. Keeps it all on the server side vs. via javascript and the browser

URL wynurl = new URL(rtn_url);   
URLConnection wynconnection = wynurl.openConnection(); 
wynconnection.setDoOutput(true);
OutputStreamWriter wynout = new OutputStreamWriter(wynconnection.getOutputStream());
wynout.write("oracleCart=" + xmlString);
wynout.close();
	
BufferedReader in = new BufferedReader(
				new InputStreamReader(
				wynconnection.getInputStream()));
				
	String decodedString;

	while ((decodedString = in.readLine()) != null) {
	    pwlog.println("Server Response: " + decodedString);
	}
	in.close(); 

	pwlog.close();

This keeps all the posting process on the server side. Seems to work well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.