Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unmonitored "Exception occurred" error on Request

Status
Not open for further replies.

dsoutherland

Programmer
Feb 26, 2004
15
am so new to ASP I'm not sure I am breathing. A company one of my clients deals with provides information over the web. They provided the ASP code for a default web site that is used to communicate with them and I have installed it and coded a VB6 app to provide the interface. Here is the problem. The ASP gets an error "Exception occurred" message. When I respond to the error, the returned XML is not received. Also, the ASP stops via the debugger at the statement and stops the whole process. The guys who supplied the code don't know why and they have been less than helpful. Here is the complete code for the ASP:

<%
'& Response.Write("version 1.0.1" & vbcrlf)
Server.ScriptTimeout = 60000
Dim xmlDoc
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.preserveWhiteSpace = TRUE

IF len(Request("XML") & "" ) > 0 THEN ''*** Error occurs here ***"
' Validate the XML String
xmlDoc.loadXML(Request("XML"))
ELSE
' Validate the XML String
xmlDoc.load(Request)
END IF

IF xmlDoc.parsed THEN
' Send Valid XML to Processor
Dim NodeName
Set xNode = xmlDoc.firstChild
IF NOT xNode IS NOTHING THEN
NodeName = xNode.nodename
IF ucase(xNode.nodename) = "XML" THEN
Set xNode = xNode.NextSibling
END IF
END IF

IF NOT xNode IS NOTHING THEN
NodeName = xNode.nodename
SELECT CASE xNode.nodename
CASE "OrderStatusResponse"
Dim objFSO, intX, fname
set objFSO = Nothing
Set objFSO = CreateObject("Scripting.FileSystemObject")
intX = 0
Do
intX = intX + 1
fname = ("E:\dac\report_received_" & Cstr(intX) & ".xml")
Loop Until objFSO.FileExists(fname) = False
IF Request.TotalBytes > 0 then
Const ForAppending = 8
Set objTextFile = objFSO.OpenTextFile(fname, ForAppending, True)
objTextFile.WriteLine(xmlDoc.xml)
END IF
objTextFile.Close
Response.Write "<XML><Status>ACCEPTED</Status></XML>"
CASE ELSE
Response.Write "<OrderStatusResponse>"
Response.Write "<ErrorDescription>"
Response.Write "<Element>XML Root</Element>"
Response.Write "<Description>ERROR - INVALID TRANSACTION</Description>"
Response.Write "<Code>Posting CSD System - default.asp: Invalid Transaction</Code>"
Response.Write "<Help>Valid transactions are OrderStatusResponse or XML. Contact IT for Help.</Help>"
Response.Write "</ErrorDescription>"
Response.Write "</OrderStatusResponse>"
END SELECT
END IF
ELSE

' Return an Error
Response.Write "<OrderStatusResponse>"
Response.Write "<ErrorDescription>"
Response.Write "<Element>XML</Element><br>"
Response.Write "<Description>XML String could not be parsed:" & xmlDoc.parseError & "</Description><br>"
Response.Write "<Code>Posting CSD System - default.asp: XML not Valid</Code><br>"
Response.Write "<Help>Make sure all tags match and are of the same case.</Help><br>"
Response.Write "</ErrorDescription>"
Response.Write "</OrderStatusResponse>"
Response.Write "<ErrorDescription>"
Response.Write "<Element>XML</Element>"
Response.Write "<Description>XML String could not be parsed:" & xmlDoc.parseError & "</Description>"
Response.Write "<Code>Customer to USIS-CSD System - default.asp: XML not Valid</Code>"
Response.Write "<Help>Make sure all tags match and are of the same case.</Help>"
Response.Write "</ErrorDescription>"
Response.Write "</OrderStatusResponse>"
END IF
%>


Any ideas?????
 
This code has never been run on any classic ASP server by anyone.

If they told you they tested it on a classic ASP server then they are misleading you.

Classic ASP uses [tt]Server.CreateObject("<blah.blah>")[/tt] instead of [tt]CreateObject("<blah.blah>")[/tt]
 
Regular VB6 and external VBS files would use CreateObject as shown in the code excerpt, but not classic ASP.
 
Okay, but this exact code has been working until about 3 days ago (Don't you hate to hear that?). We went out of a test situation and into a production situation then (same everything only allowed all users to use the feature) and the only change I could tell you would be would be volume. The page works most of the time.

If I change the code you indicated, will that stop the exception error messaage on the "IF len(Request("XML") & "" ) > 0 THEN" statement that stops the page??
 
/blush [blush]

What you say is true... It is possible to use CreateObject assuming you dont want to use MTS/COM+

However, it is a bad idea because it doesn't scale up very well. Even if your app does not use transactions and your objects do not interact directly with the Request and Response objects, yhou should still use Server.CreateObject.

When you use Server.CreateObject, the object is created in the context of the current ASP page and the object reference count is valid inside the page so if you destroy the object it will actually be ready for COM garbage collection.

If you just use CreateObject then it is created and counted in the context of the ASP engine instead of the single page. This can cause excess memory usage when the server gets busy. It can also cause problems where the threading model of the object is important to garbage collection.

Anyway, this seems not exactly the cause of the "exception occurred" error.

This does bring to mind the problem where the original microsoft xml parser would not always work well in ASP especially under heavy load. It was a threading problem and they fixed it by releasing a "server-safe" version of the object named "MSXML2.ServerXMLHTTP." Perhaps there is a similar situation with your object?
 
Thanks for the explanation, Sheco!

So, what does that mean: "a 'server-safe' version of the object named "MSXML2.ServerXMLHTTP." for me and my problem? How would I make the changes necessary to correct the situation? Incidentally, I have been monitoring this pretty closely today and I can tell you it has nothing to do with volume. The error popped up on the first transaction after 30 minutes of idle time.
 
I'm not sure if it has anything to do with the problem... it just reminded me of a situation with a different Microsoft XML object that would work when testing but fail in production. With that object the prob turned out to be something MS fixed with a new version of the object... so maybe there is a server version of your object... just a guess is all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top