asburythug
07-23-2003, 03:15 PM
hey all, i'm trying to use the javascript xmlhttp object to post xml for the UPS freight calculation. But when I try to run my code below, i get the same error response...but it just looks like the UPS server is not recognizing the message that i am sending it.
<head>
<script TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function send_xml(strXML){
// Create xml object with default header and primary node
var xmlUPS = new ActiveXObject("MSXML2.DOMDocument");
xmlUPS.loadXML('<?xml version="1.0"?><AccessRequest xml:lang="en-US"><AccessLicenseNumber>CB9B1D2149FA4C98</AccessLicenseNumber><UserId>echang</UserId><Password>password</Password></AccessRequest>');
// Create an instance of the XML HTTP Request object
var ups_xmlhttp = new ActiveXObject( "msxml2.XMLHTTP" );
// Prepare the XMLHTTP object for a http post
ups_xmlhttp.open( "POST", "https://wwwcie.ups.com/ups.app/xml/Rate", false );
ups_xmlhttp.setRequestHeader("Method", "POST");
ups_xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ups_xmlhttp.setRequestHeader("Content-Length", 181);
// Execute the request
ups_xmlhttp.send(xmlUPS);
if (ups_xmlhttp) {
return ups_xmlhttp.responseXML;
}
-->
</script>
</head>
<form name="the_form" action="https://wwwcie.ups.com/ups.app/xml/Rate" method="post" onSubmit="return send_xml(text_input.value)">
<p> xml request: <textarea name="text_input" rows=20 cols=100></textarea><br><br>
<input type=submit> <input type=reset>
</form>
Is there anything wrong with my javascript code? Has anybody been able to successfully post an xml file to UPS (or a similar service)? If UPS requires that transmissions be done using SSL, is there anything i have to specify from the client-javascript end? Any help or insight would very much be appreciated...thanks.
<head>
<script TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function send_xml(strXML){
// Create xml object with default header and primary node
var xmlUPS = new ActiveXObject("MSXML2.DOMDocument");
xmlUPS.loadXML('<?xml version="1.0"?><AccessRequest xml:lang="en-US"><AccessLicenseNumber>CB9B1D2149FA4C98</AccessLicenseNumber><UserId>echang</UserId><Password>password</Password></AccessRequest>');
// Create an instance of the XML HTTP Request object
var ups_xmlhttp = new ActiveXObject( "msxml2.XMLHTTP" );
// Prepare the XMLHTTP object for a http post
ups_xmlhttp.open( "POST", "https://wwwcie.ups.com/ups.app/xml/Rate", false );
ups_xmlhttp.setRequestHeader("Method", "POST");
ups_xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ups_xmlhttp.setRequestHeader("Content-Length", 181);
// Execute the request
ups_xmlhttp.send(xmlUPS);
if (ups_xmlhttp) {
return ups_xmlhttp.responseXML;
}
-->
</script>
</head>
<form name="the_form" action="https://wwwcie.ups.com/ups.app/xml/Rate" method="post" onSubmit="return send_xml(text_input.value)">
<p> xml request: <textarea name="text_input" rows=20 cols=100></textarea><br><br>
<input type=submit> <input type=reset>
</form>
Is there anything wrong with my javascript code? Has anybody been able to successfully post an xml file to UPS (or a similar service)? If UPS requires that transmissions be done using SSL, is there anything i have to specify from the client-javascript end? Any help or insight would very much be appreciated...thanks.