Security Error every other SOAP call

J

jim.pacyga2

I am working on a small web page that uses Javascript in Firefox 2.0 to
make SOAP calls. The page is loaded from the local machine as a file
(file:///C:/...., no web server used), and the SOAP server process is
running on the local machine (http://localhost:7090). I can make my
SOAP call with its single parameter ( Create-EVNT(xml) ) without any
problems, and I receive the return value (a single string) without any
problems as well.

The issue I'm having is that when I make the same, identical SOAP call
a second time, by clicking my HTML form button again, I get the
following Javascript error in the console:

uncaught exception: Security Error: Content at file:/// may not load
data from http://localhost:7090.

However, the THIRD time I try to make the SOAP call, I am able to
without any issues. So essentially, every other SOAP call gets the
error stated above. Also, when I try to reload the page before the 2nd
SOAP call, I get the following error:

parse_event_data is not defined

This is very strange, since the Javascript function IS available. It's
like the page is in a funky state or something. If I reload the page
yet again, the SOAP call goes back to working every other time.

I have been unsuccessful in finding the root cause of the problem, and
was wondering what insight the community had. I'm including both the
Javascript file (create_event.js) and the HTML file (create_event.html)
at the bottom of this post.

Thanks in advance!!
Jim

create_event.html
-----------------------------

<html>

<head>
<script src="create_event.js"/>
</head>

<body bgcolor="#C7C7C7">
<table width="100%" align="center" cellspacing="0" cellpadding="12"
border="0" bgcolor="#C7C7C7" ><tr><td>
<table width="100%" align="center" cellspacing="4" cellpadding="3"
border="0" bgcolor="#000000" ><tr><td bgcolor="#808F8F" >
<table width="100%" align="center" cellspacing="0" cellpadding="20"
border="0" bgcolor="#F0F0F0" ><tr><td bgcolor="#F0F0F0" >

<h2>Create Event</h2>

<form action="" method="get">

<font color="red">*</font> Operator ID: <br>
<input type="text" name="operatorID">

<br><br>

<font color="red">*</font> Operator Input: <br>
<textarea name="operatorInput"></textarea>

<br><br>

<input type="button" name="create_event_button" value="Create Event"
onClick="parse_event_data( this.form )">

<input type="button" name="clear_form_button" value="Clear Form"
onClick="clear_form( this.form )">

</form>

<i><font color="red">*</font> is a required field.</i>

</table>
</td></tr></table>
</td></tr></table>
</td></tr></table>

</body>
</html>


create_event.js
-----------------------

function clear_form( form )
{
form.operatorID.value = "";
form.operatorInput.value = "";
}


function handleSOAPResponse( response, call, status )
{
// Failure in calling the service
if( status != 0 )
{
alert("SOAP service failure." + error);
return false;
}
else
{
// Error in call
if( response.fault != null)
{
alert("SOAP Fault:\n\n" + "Code: " + response.fault.faultCode
+
"\n\nMessage: " + response.fault.faultString);
return false;
}

/*
* IF WE WANT TO DO SOMETHING WITH THE RETURN VALUE, FILL IT IN
HERE.
*/

// All went well
num = new Object(); // Holds number of parameters returned
param = response.getParameters(false,num); // 'false' means RPC
call

alert( "Got value of " + param[0].value );
}
}


function call_create_evnt( data )
{
// Organize SOAP call parameters
params = new Array();
params[0] = new SOAPParameter( data, "xml" );

try {
netscape.security.PrivilegeManager.enablePrivilege(
"UniversalBrowserRead" );
}
catch( e ) {
alert( "Error asking for Gecko privileges: " + e );
return false;
}

// Make SOAP call
soapCall = new SOAPCall();
soapCall.transportURI = "http://localhost:7090"
soapCall.encode( 0, "Create-EVNT", "urn:DSB",
0, null,
params.length, params );
soapCall.asyncInvoke( handleSOAPResponse );

// REMOVE ME
//alert( data );
}


function parse_event_data( form )
{
// Basic error checking for fields
if( form.operatorID.value == "" || form.operatorInput.value == "" )
{
alert( "Please enter data into all required fields." );
return false;
}

// If we can do the XML stuff in Gecko, do it
if( ! (document.implementation) ||
! (document.implementation.createDocument) )
{
alert("Could not initialize DOM of Gecko browser.");
return false;
}

// Create new XML document, and get a reference to the root node
xmlDoc = document.implementation.createDocument( "", "EVNT", null );
root_elem = xmlDoc.getElementsByTagName( "EVNT");

// Get current date and time
today = new Date();
current_year = today.getFullYear();
current_month = today.getMonth() + 1;
current_date = today.getDate();

current_hour = today.getHours();
if( current_hour < 10 )
{
current_hour = "0" + current_hour;
}

current_minute = today.getMinutes();
if( current_minute < 10 )
{
current_minute = "0" + current_minute;
}

current_second = today.getSeconds();
if( current_second < 10 )
{
current_second = "0" + current_second;
}

timestamp = current_year + "-" + current_month + "-" + current_date
+ "T" +
current_hour + ":" + current_minute + ":" +
current_second;


// Set all attributes in the node
root_elem[0].setAttribute( "operatorID", form.operatorID.value );
root_elem[0].setAttribute( "operatorInput", form.operatorInput.value
);
root_elem[0].setAttribute( "dateTimeStamp", timestamp );

theXML = new XMLSerializer().serializeToString( xmlDoc );

// Prepend the necessary XML header, as well as the XSLT that will
make
// the XML look pretty in the record book viewer.
theXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<?xml-stylesheet type=\"text/xsl\"
href=\"file://C:/EVNT.xslt\"?>" + theXML;

// Make SOAP call
call_create_evnt( theXML );
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top