By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,369 Members | 1,550 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,369 IT Pros & Developers. It's quick & easy.

XML document must have a top level element

P: n/a
Hi all,

I had a program and it always works fine and suddenly it gives me the
following message when a pass a xml file to our server program:
error code: -1072896680 reason: XML document must have a top level element.
line #: 0
I don't know if it is my xml file or it is something else?

Here is my client side program:
<%@ Language=vbScript%>
<%
Set xmlDom=CreateObject("Microsoft.XMLDOM")

XMLDom.async =False
xmlDom.load Server.MapPath("05272008ACTest.xml")
DataToSend = xmlDom.xml

dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")

xmlhttp.Open "POST","https://www.mydomain.com/ac/xt_ac_B2B.asp",false

xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

xmlhttp.send DataToSend
if(Err <0) then
Response.Write("An error occured when retrieving data from an external
source.<br />")
Response.Write(Err.Description)
Response.End
end if
On error goto 0
'if request is not Ok then display detailed message about the request
problem
if(xmlHttp.status <200) then
Response.Write("The remote server returned an invalid statuscode: #8221;"
& _
xmlHttp.status & " " & xmlHttp.statusText) & "<br>"
Response.Write("response text from remote server" & _
" " & xmlHttp.responseText)
Response.End
end if

if xmlHttp.responseXML is nothing then
Response.Write("The remote server didn’t return xml content.")
Response.End
end if
Response.ContentType = "text/xml"
Response.Write xmlhttp.responsexml.xml
Set xmlhttp = nothing
%>

and 05272008ACTest.xml file is like this:
- <enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E" productName="adventureCenter">
<test>Y</test>
<residency>US</residency>
- <coverageOption>
<partI totalPartIPayment="12.55">Y</partI>
<partII totalPartIPayment="">N</partII>
</coverageOption>
<tripName>European Tour</tripName>
<enrollmentFee>5.00</enrollmentFee>
<totalPayment>765.00</totalPayment>
<tripDates departureDate="5/14/2007" returnDate="5/17/2007" tripDays="4" />
<numofParticipant>3</numofParticipant>
- <participants>
<participant firstName="Cindy" mInit="b" lastName="Rose"
birthdate="4/26/1955" tripCost="2500" partIPremium="187.50"
partIIPremium="25.00" />
<participant firstName="Kathy" mInit="c" lastName="Barlow"
birthdate="6/28/1944" tripCost="2500" partIPremium="262.50"
partIIPremium="35.00" />
<participant firstName="Matthrew" mInit="d" lastName="Kaminski"
birthdate="4/27/1933" tripCost="2500" partIPremium="300.00"
partIIPremium="45.00" />
</participants>
<mailingInfo name="Betty Sun" address="4406 Larwin ct." city="Concord"
state="CA" province="" zip="12345" country="United States" />
<email>su******@yahoo.com</email>
- <phone>
<homePhone number="4057887933">Y</homePhone>
<bizPhone>N</bizPhone>
</phone>
<enrollAgreement>Y</enrollAgreement>
- <payment>
<method>card</method>
<billingAddress name="Betty Sun" street="4406 larwin ct." city="Concord"
state="CA" province="" country="United States" />
<creditCard type="visa" number="4XXXXXXXXXXXXXX" expDate="7/2007" />
</payment>
</enrollment>

and My server program is like this:

Dim xmlDoc, InstreamXMLRoot, TestFlag

Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.Load Request '--this is for xml sent via body

Response.ContentType = "text/xml" '--for testing program

'***********************************
'the server program complains here, but the funny thing
is I save the stream on the server and the file looks the same
as it is passed and it displays in the browser very well, I don't get it!!!!!
'***********************************
If xmlDoc.parseError.errorCode <0 Then
Call UpdateXMLResponse(orderID, "False", "XML", "error code: "
&xmlDoc.parseError.errorCode & " reason: " &xmlDoc.parseError.reason &" line
#: " &xmlDoc.parseError.line , "")
End If

IF isNULL(xmlDoc) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF

Set InstreamXMLRoot=xmlDoc.documentElement
IF isNULL(InstreamXMLRoot) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Server.MapPath("B2BResponse/" & hour(now) & "_" & minute(now) &
"_" & RandomNumber(1000000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse.xml"))

--
Betty
Aug 23 '08 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"c676228" <be***@newsgroup.nospamwrote in message
news:40**********************************@microsof t.com...
Hi all,

I had a program and it always works fine and suddenly it gives me the
following message when a pass a xml file to our server program:
error code: -1072896680 reason: XML document must have a top level
element.
line #: 0
I don't know if it is my xml file or it is something else?
Hmm, I can't see anything that would cause this error. It might help if we
tweak the code a bit. Inline ...
Here is my client side program:
<%@ Language=vbScript%>
<%
Set xmlDom=CreateObject("Microsoft.XMLDOM")
Use MSXML2.DOMDocument.3.0
XMLDom.async =False
xmlDom.load Server.MapPath("05272008ACTest.xml")
DataToSend = xmlDom.xml
Don't need the above line, delete it.

>
dim xmlhttp
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
Belts and braces use MSXML2.ServerXMLHTTP.3.0
xmlhttp.Open "POST","https://www.mydomain.com/ac/xt_ac_B2B.asp",false

xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
>
You're not sending a HTML form post. You don't need the above line delete
it
xmlhttp.send DataToSend
The xmlHttp object knows how to send an XML DOM change the line to:-

xmlhttp.send xmlDom

Note this will add the correct content type header.
if(Err <0) then
Response.Write("An error occured when retrieving data from an external
source.<br />")
Response.Write(Err.Description)
Response.End
end if
On error goto 0
'if request is not Ok then display detailed message about the request
problem
if(xmlHttp.status <200) then
Response.Write("The remote server returned an invalid statuscode:
#8221;"
& _
xmlHttp.status & " " & xmlHttp.statusText) & "<br>"
Response.Write("response text from remote server" & _
" " & xmlHttp.responseText)
Response.End
end if

if xmlHttp.responseXML is nothing then
Response.Write("The remote server didn't return xml content.")
Response.End
end if
Response.ContentType = "text/xml"
You should be getting UTF-8 from the server and that is what you want be
sending add:-

Response.CharSet = "UTF-8"
Response.Write xmlhttp.responsexml.xml
This can really mess up the character encoding use instead:-

xmlhttp.responseXML.save Response

Set xmlhttp = nothing
%>

and 05272008ACTest.xml file is like this:
It would help if you posted the actual file content rather than what is seen
in IE browser. Especially important is the start of the file. Make sure
the file has no whitespace at the start. Also open the file in notepad then
use Save As to check what encoding it is in.
- <enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E" productName="adventureCenter">
<test>Y</test>
<residency>US</residency>
- <coverageOption>
<partI totalPartIPayment="12.55">Y</partI>
<partII totalPartIPayment="">N</partII>
</coverageOption>
<tripName>European Tour</tripName>
<enrollmentFee>5.00</enrollmentFee>
<totalPayment>765.00</totalPayment>
<tripDates departureDate="5/14/2007" returnDate="5/17/2007" tripDays="4"
/>
<numofParticipant>3</numofParticipant>
- <participants>
<participant firstName="Cindy" mInit="b" lastName="Rose"
birthdate="4/26/1955" tripCost="2500" partIPremium="187.50"
partIIPremium="25.00" />
<participant firstName="Kathy" mInit="c" lastName="Barlow"
birthdate="6/28/1944" tripCost="2500" partIPremium="262.50"
partIIPremium="35.00" />
<participant firstName="Matthrew" mInit="d" lastName="Kaminski"
birthdate="4/27/1933" tripCost="2500" partIPremium="300.00"
partIIPremium="45.00" />
</participants>
<mailingInfo name="Betty Sun" address="4406 Larwin ct." city="Concord"
state="CA" province="" zip="12345" country="United States" />
<email>su******@yahoo.com</email>
- <phone>
<homePhone number="4057887933">Y</homePhone>
<bizPhone>N</bizPhone>
</phone>
<enrollAgreement>Y</enrollAgreement>
- <payment>
<method>card</method>
<billingAddress name="Betty Sun" street="4406 larwin ct." city="Concord"
state="CA" province="" country="United States" />
<creditCard type="visa" number="4XXXXXXXXXXXXXX" expDate="7/2007" />
</payment>
</enrollment>

and My server program is like this:

Dim xmlDoc, InstreamXMLRoot, TestFlag

Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
Again use MSXML2.DOMDocument.3.0

xmlDoc.Load Request '--this is for xml sent via body

Response.ContentType = "text/xml" '--for testing program

'***********************************
'the server program complains here, but the funny thing
is I save the stream on the server and the file looks the same
as it is passed and it displays in the browser very well, I don't get
it!!!!!
'***********************************
If xmlDoc.parseError.errorCode <0 Then
Call UpdateXMLResponse(orderID, "False", "XML", "error code: "
&xmlDoc.parseError.errorCode & " reason: " &xmlDoc.parseError.reason &"
line
#: " &xmlDoc.parseError.line , "")
End If

IF isNULL(xmlDoc) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF

Set InstreamXMLRoot=xmlDoc.documentElement
IF isNULL(InstreamXMLRoot) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Server.MapPath("B2BResponse/" & hour(now) & "_" & minute(now)
&
"_" & RandomNumber(1000000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse.xml"))
Can't see where you are sending the XML response. However you would
probably want to build the response in an XML DOM and use:-

Response.ContentType = "text/xml" ' Yes move this line to where you send the
response
Response.CharSet = "UTF-8"
dom.Save Response
Also have you tested via Http instead of https do you get the same result.

Make this bunch of changes see if it fixes things (or least breaks in a
different way that we can help you with ;)
--
Anthony Jones - MVP ASP/ASP.NET
Aug 23 '08 #2

P: n/a

"c676228" wrote:
and 05272008ACTest.xml file is like this:
- <enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E" productName="adventureCenter">
<test>Y</test>
<residency>US</residency>
....

There is no
<? xml .... ?>
line there. If you are simply viewing the XML file via MSIE, that line
*should* be showing up.

An example of a valid header line would be
<? xml version="1.0" encoding="windows-1252" ?>

(Encoding could also be "utf-8". Many sites also use "iso-8859-1" but
that's almost always a mistake.)

Aug 23 '08 #3

P: n/a
"Old Pedant" <Ol*******@discussions.microsoft.comwrote in message
news:7B**********************************@microsof t.com...
>
"c676228" wrote:
and 05272008ACTest.xml file is like this:
- <enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E" productName="adventureCenter">
<test>Y</test>
<residency>US</residency>
...

There is no
<? xml .... ?>
line there. If you are simply viewing the XML file via MSIE, that line
*should* be showing up.

An example of a valid header line would be
<? xml version="1.0" encoding="windows-1252" ?>

(Encoding could also be "utf-8". Many sites also use "iso-8859-1" but
that's almost always a mistake.)
An XML declaration is not mandatory; MSXML will quite happily load XML
without it. However it is probably bettter that it be present.

--
Anthony Jones - MVP ASP/ASP.NET
Aug 23 '08 #4

P: n/a
Hi Anthony and Old Pedant,
Now my b2bresponse.xml and 05272008ACTest.xml file have a line:
<?xml version="1.0" encoding="UTF-8" ?>

and in firefox: I still get the same error:
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>

<errorMessage>
error code: -1072896680 reason: XML document must have a top level element.
line #: 0
</errorMessage>
<policyNumber/>
</xmlResponse>

in IE I have to use view source to see the following message:
<?xml version="1.0"?>
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>
<errorMessage>error code: -1072896680 reason: XML document must have a top
level element.
line #: 0</errorMessage>
<policyNumber/>
</xmlResponse>

In IE broswer, it just looks like this:
False XML error code: -1072896680 reason: XML document must have a top level
element. line #: 0

the same all xml files in UTF-8 code in the notepad already.
I really don't know what to do.

--
Betty
"Anthony Jones" wrote:
"Old Pedant" <Ol*******@discussions.microsoft.comwrote in message
news:7B**********************************@microsof t.com...

"c676228" wrote:
and 05272008ACTest.xml file is like this:
- <enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E" productName="adventureCenter">
<test>Y</test>
<residency>US</residency>
...

There is no
<? xml .... ?>
line there. If you are simply viewing the XML file via MSIE, that line
*should* be showing up.

An example of a valid header line would be
<? xml version="1.0" encoding="windows-1252" ?>

(Encoding could also be "utf-8". Many sites also use "iso-8859-1" but
that's almost always a mistake.)

An XML declaration is not mandatory; MSXML will quite happily load XML
without it. However it is probably bettter that it be present.

--
Anthony Jones - MVP ASP/ASP.NET
Aug 24 '08 #5

P: n/a


"c676228" <be***@newsgroup.nospamwrote in message
news:9E**********************************@microsof t.com...
Hi Anthony and Old Pedant,
Now my b2bresponse.xml and 05272008ACTest.xml file have a line:
<?xml version="1.0" encoding="UTF-8" ?>

and in firefox: I still get the same error:
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>
?
<errorMessage>
error code: -1072896680 reason: XML document must have a top level
element.
line #: 0
</errorMessage>
<policyNumber/>
</xmlResponse>

in IE I have to use view source to see the following message:
<?xml version="1.0"?>
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>
<errorMessage>error code: -1072896680 reason: XML document must have a top
level element.
line #: 0</errorMessage>
<policyNumber/>
</xmlResponse>

In IE broswer, it just looks like this:
False XML error code: -1072896680 reason: XML document must have a top
level
element. line #: 0

the same all xml files in UTF-8 code in the notepad already.
I really don't know what to do.
Did you make the adjustments to the code I outlined? Have you tried it via
http instead of https?
--
Anthony Jones - MVP ASP/ASP.NET
Aug 24 '08 #6

P: n/a
"c676228" <be***@newsgroup.nospamwrote in message
news:40**********************************@microsof t.com...
Hi all,

I had a program and it always works fine and suddenly it gives me the
following message when a pass a xml file to our server program:
error code: -1072896680 reason: XML document must have a top level
element.
line #: 0
I don't know if it is my xml file or it is something else?
<snip>
>
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")

D'oh! I think I see it now try inserting the following here:-

xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body

Response.ContentType = "text/xml" '--for testing program
<snip>
I still think you should make the other tweaks I recommended as well. ;)
--
Anthony Jones - MVP ASP/ASP.NET
Aug 24 '08 #7

P: n/a
Anthony,

Yes, I followed your directions and here is the new code. The funny part is
I think i used the same way as I coded before and how come it suddenly
doesn't work any more.
Now I tried to debug the xml file step by step. so my xml file first will
look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<enrollment orderID="200808251114527143" PONumber="50000" marketingCode="E"
productName="adventureCenter">
</enrollment>

Ok, no xml needs a top element error message.

so I changed the xml file to:

<?xml version="1.0" encoding="UTF-8" ?>
<enrollment orderID="200808251114527143" PONumber="50000" marketingCode="E"
productName="adventureCenter">
<test>Y</test>
</enrollment>

Only one extra line: <test>Y</testbesides the top element.
Now it complains again:
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>

<errorMessage>
error code: -1072896680 reason: XML document must have a top level element.
line #: 0
</errorMessage>
<policyNumber/>
</xmlResponse>
It seems it only takes a top level element xml file, as soon as I add one
more line to the xml file, it starts to complain. I don't get it.

'*************************************
Server side:
'*************************************
Dim xmlDoc, InstreamXMLRoot, TestFlag
Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument.3.0 ") '8/23/2008
xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body

Response.ContentType = "text/xml" '--for testing program

If xmlDoc.parseError.errorCode <0 Then
Call UpdateXMLResponse(orderID, "False", "XML", "error code: "
&xmlDoc.parseError.errorCode & " reason: " &xmlDoc.parseError.reason &" line
#: " &xmlDoc.parseError.line , "")
End If

IF isNULL(xmlDoc) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF

Set InstreamXMLRoot=xmlDoc.documentElement
IF isNULL(InstreamXMLRoot) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Server.MapPath("B2BResponse/" & hour(now) & "_" & minute(now) &
"_" & RandomNumber(1000000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse.xml"))
'check if this is production transaction
Call UpdateXMLResponse(orderID, "False", "XML", "The server received the XML
stream", "")
'************************************************* ************
' Update B2B Response ''Response.ContentType="text/xml"
'************************************************* ************
Function UpdateXMLResponse(byVal order_id, byVal SuccFlag, byVal ErrField,
byVal Desc, byVal PolicyNum)
'Set RespInfo=Server.CreateObject("Microsoft.XMLDOM")
Set RespInfo=CreateObject("MSXML2.DOMDocument.3.0")
RespInfo.async=False
RespInfo.load(server.MapPath("/Utility/B2BResponse.xml"))
Set RespInfoRoot=RespInfo.documentElement
Set SuccessNode=RespInfoRoot.selectSingleNode("isSucce ss")
SuccessNode.Text=SuccFlag
If SuccFlag="True" Then
Set PolicyNode=RespInfoRoot.selectSingleNode("policyNu mber")
PolicyNode.Text=PolicyNum
Else
Set ErrNode=RespInfoRoot.selectSingleNode("errorField" )
ErrNode.Text=ErrField
Set DescNode=RespInfoRoot.selectSingleNode("errorMessa ge")
DescNode.Text=Desc
End If

If order_id <>"" Then
RespInfo.save(server.MapPath("B2BResponse/" & order_id &"_B2BResponse.xml"))
Else
RespInfo.save(server.MapPath("B2BResponse/" & month(now) & "_" & day(now)
& "_" & RandomNumber(1000000) & "_" & year(now) &"_B2BResponse.xml"))
End If%>

<%
Response.ContentType = "text/xml"
Response.Write RespInfo.xml
Set RespInfo=Nothing
Response.End

End Function
'****************************
B2Bresponse.xml is like this:
'****************************
<xmlResponse>
<isSuccess />
<errorField />
<errorMessage />
<policyNumber />
</xmlResponse>

'**********************
Client side program is like this:
'**********************
<%@ Language=vbScript%>
<%
'Set xmlDom=CreateObject("Microsoft.XMLDOM")
set xmlDom=CreateObject("MSXML2.DOMDocument.3.0")

XMLDom.async =False
xmlDom.load Server.MapPath("08242008ACTest.xml")

dim xmlhttp
set xmlhttp=server.CreateObject("MSXML2.ServerXMLHTTP. 3.0") '8/23/2008

xmlhttp.Open
"POST","https://www.travelinsuranceservices.com/ac/xt_ac_B2B.asp",false
xmlhttp.send xmlDom '8/23/2008
if(Err <0) then
Response.Write("An error occured when retrieving data from an external
source.<br />")
Response.Write(Err.Description)
Response.End
end if
On error goto 0
'if request is not Ok then display detailed message about the request
problem
if(xmlHttp.status <200) then
Response.Write("The remote server returned an invalid statuscode: #8221;"
& _
xmlHttp.status & " " & xmlHttp.statusText) & "<br>"
Response.Write("response text from remote server" & _
" " & xmlHttp.responseText)
Response.End
end if

if xmlHttp.responseXML is nothing then
Response.Write("The remote server didn’t return xml content.")
Response.End
end if
Response.ContentType = "text/xml"
Response.CharSet = "UTF-8"
'Response.Write xmlhttp.responsexml.xml
xmlhttp.responseXML.save Response
Set xmlhttp = nothing
%>
--
Betty
"Anthony Jones" wrote:
"c676228" <be***@newsgroup.nospamwrote in message
news:40**********************************@microsof t.com...
Hi all,

I had a program and it always works fine and suddenly it gives me the
following message when a pass a xml file to our server program:
error code: -1072896680 reason: XML document must have a top level
element.
line #: 0
I don't know if it is my xml file or it is something else?

<snip>

Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")


D'oh! I think I see it now try inserting the following here:-

xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body

Response.ContentType = "text/xml" '--for testing program

<snip>
I still think you should make the other tweaks I recommended as well. ;)
--
Anthony Jones - MVP ASP/ASP.NET
Aug 25 '08 #8

P: n/a
Yes, I did. See another reply in details.
I used https, I cannot use http. If I used http, it will have the following
error messge:
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Technical Information (for support personnel)

* Error Type:
msxml3.dll (0x80070005)
Access is denied.
/08232008adventureServerHttp.asp, line 13

line 12 and 13 are:
12: xmlhttp.Open
"POST","http://www.travelinsuranceservices.com/ac/xt_ac_B2B.asp",false
13: xmlhttp.send xmlDom '8/23/2008
--
Betty
"Anthony Jones" wrote:
>

"c676228" <be***@newsgroup.nospamwrote in message
news:9E**********************************@microsof t.com...
Hi Anthony and Old Pedant,
Now my b2bresponse.xml and 05272008ACTest.xml file have a line:
<?xml version="1.0" encoding="UTF-8" ?>

and in firefox: I still get the same error:
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>
?
<errorMessage>
error code: -1072896680 reason: XML document must have a top level
element.
line #: 0
</errorMessage>
<policyNumber/>
</xmlResponse>

in IE I have to use view source to see the following message:
<?xml version="1.0"?>
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>
<errorMessage>error code: -1072896680 reason: XML document must have a top
level element.
line #: 0</errorMessage>
<policyNumber/>
</xmlResponse>

In IE broswer, it just looks like this:
False XML error code: -1072896680 reason: XML document must have a top
level
element. line #: 0

the same all xml files in UTF-8 code in the notepad already.
I really don't know what to do.

Did you make the adjustments to the code I outlined? Have you tried it via
http instead of https?
--
Anthony Jones - MVP ASP/ASP.NET
Aug 25 '08 #9

P: n/a
"c676228" <be***@newsgroup.nospamwrote in message
news:F2**********************************@microsof t.com...
Anthony,

Yes, I followed your directions and here is the new code. The funny part
is
I think i used the same way as I coded before and how come it suddenly
doesn't work any more.
Now I tried to debug the xml file step by step. so my xml file first will
look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E"
productName="adventureCenter">
</enrollment>

Ok, no xml needs a top element error message.

so I changed the xml file to:

<?xml version="1.0" encoding="UTF-8" ?>
<enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E"
productName="adventureCenter">
<test>Y</test>
</enrollment>

Only one extra line: <test>Y</testbesides the top element.
Now it complains again:
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>
?
<errorMessage>
error code: -1072896680 reason: XML document must have a top level
element.
line #: 0
</errorMessage>
<policyNumber/>
</xmlResponse>
It seems it only takes a top level element xml file, as soon as I add one
more line to the xml file, it starts to complain. I don't get it.

'*************************************
Server side:
'*************************************
Dim xmlDoc, InstreamXMLRoot, TestFlag
Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument.3.0 ") '8/23/2008
xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body

Response.ContentType = "text/xml" '--for testing program

If xmlDoc.parseError.errorCode <0 Then
Call UpdateXMLResponse(orderID, "False", "XML", "error code: "
&xmlDoc.parseError.errorCode & " reason: " &xmlDoc.parseError.reason &"
line
#: " &xmlDoc.parseError.line , "")
End If

IF isNULL(xmlDoc) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF

Set InstreamXMLRoot=xmlDoc.documentElement
IF isNULL(InstreamXMLRoot) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Server.MapPath("B2BResponse/" & hour(now) & "_" & minute(now)
&
"_" & RandomNumber(1000000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse.xml"))
'check if this is production transaction
Call UpdateXMLResponse(orderID, "False", "XML", "The server received the
XML
stream", "")

Hmm... perplexing. Are we seeing all the Server code here? Do you have
other code prior to the above which reads the Request object? Note the
Request stream doesn't support reseting position to the beginning, therefore
once read, it cannot be read again. If you have already consumed the
request stream elsewhere I suspect your code would respond in the way you
are seeing.
--
Anthony Jones - MVP ASP/ASP.NET
Aug 25 '08 #10

P: n/a
Hi Anthony,
>Do you have
other code prior to the above which reads the Request object?
Thank you, thank you, thank you!!!!!
It is all because my cut and paste problems and I have the following code in
different files --->meaning I have xmlDoc.Load Request statement two times.
And I never know this will cause this deadly error.
Besides I never know that Request stream doesn't support reset position.
You are my life saver. I have been pulling my hair for 3 days and don't know
what to do.
:=)))
Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument.3.0 ") '8/23/2008
xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body
'xmlDoc.LoadXML Request("xml") '--this is for xml sent via form field
xml="xml string", squreMouth production version
Response.ContentType = "text/xml" '--for testing program

If xmlDoc.parseError.errorCode <0 Then
'Response.write("Error code: " + xmlDoc.parseError.errorCode)
'Response.write("<br />Error reason: " + xmlDoc.parseError.reason)
'Response.write("<br />Error line: " + xmlDoc.parseError.line)
Call UpdateXMLResponse(orderID, "False", "XML", "error code: "
&xmlDoc.parseError.errorCode & " reason: " &xmlDoc.parseError.reason &" line
#: " &xmlDoc.parseError.line , "")
End If

IF isNULL(xmlDoc) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
Betty
"Anthony Jones" wrote:
"c676228" <be***@newsgroup.nospamwrote in message
news:F2**********************************@microsof t.com...
Anthony,

Yes, I followed your directions and here is the new code. The funny part
is
I think i used the same way as I coded before and how come it suddenly
doesn't work any more.
Now I tried to debug the xml file step by step. so my xml file first will
look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E"
productName="adventureCenter">
</enrollment>

Ok, no xml needs a top element error message.

so I changed the xml file to:

<?xml version="1.0" encoding="UTF-8" ?>
<enrollment orderID="200808251114527143" PONumber="50000"
marketingCode="E"
productName="adventureCenter">
<test>Y</test>
</enrollment>

Only one extra line: <test>Y</testbesides the top element.
Now it complains again:
<xmlResponse>
<isSuccess>False</isSuccess>
<errorField>XML</errorField>
?
<errorMessage>
error code: -1072896680 reason: XML document must have a top level
element.
line #: 0
</errorMessage>
<policyNumber/>
</xmlResponse>
It seems it only takes a top level element xml file, as soon as I add one
more line to the xml file, it starts to complain. I don't get it.

'*************************************
Server side:
'*************************************
Dim xmlDoc, InstreamXMLRoot, TestFlag
Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument.3.0 ") '8/23/2008
xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body

Response.ContentType = "text/xml" '--for testing program

If xmlDoc.parseError.errorCode <0 Then
Call UpdateXMLResponse(orderID, "False", "XML", "error code: "
&xmlDoc.parseError.errorCode & " reason: " &xmlDoc.parseError.reason &"
line
#: " &xmlDoc.parseError.line , "")
End If

IF isNULL(xmlDoc) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF

Set InstreamXMLRoot=xmlDoc.documentElement
IF isNULL(InstreamXMLRoot) Then
Set InstreamXMLRoot=Nothing
Call UpdateXMLResponse(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Server.MapPath("B2BResponse/" & hour(now) & "_" & minute(now)
&
"_" & RandomNumber(1000000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse.xml"))
'check if this is production transaction
Call UpdateXMLResponse(orderID, "False", "XML", "The server received the
XML
stream", "")


Hmm... perplexing. Are we seeing all the Server code here? Do you have
other code prior to the above which reads the Request object? Note the
Request stream doesn't support reseting position to the beginning, therefore
once read, it cannot be read again. If you have already consumed the
request stream elsewhere I suspect your code would respond in the way you
are seeing.
--
Anthony Jones - MVP ASP/ASP.NET
Aug 26 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.