473,729 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML document must have a top level element

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=vbScri pt%>
<%
Set xmlDom=CreateOb ject("Microsoft .XMLDOM")

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

dim xmlhttp
set xmlhttp = server.Createob ject("MSXML2.Se rverXMLHTTP")

xmlhttp.Open "POST","htt ps://www.mydomain.co m/ac/xt_ac_B2B.asp", false

xmlhttp.setRequ estHeader "Content-Type", "applicatio n/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.stat us <200) then
Response.Write( "The remote server returned an invalid statuscode: #8221;"
& _
xmlHttp.status & " " & xmlHttp.statusT ext) & "<br>"
Response.Write( "response text from remote server" & _
" " & xmlHttp.respons eText)
Response.End
end if

if xmlHttp.respons eXML is nothing then
Response.Write( "The remote server didn’t return xml content.")
Response.End
end if
Response.Conten tType = "text/xml"
Response.Write xmlhttp.respons exml.xml
Set xmlhttp = nothing
%>

and 05272008ACTest. xml file is like this:
- <enrollment orderID="200808 251114527143" PONumber="50000 "
marketingCode=" E" productName="ad ventureCenter">
<test>Y</test>
<residency>US </residency>
- <coverageOption >
<partI totalPartIPayme nt="12.55">Y</partI>
<partII totalPartIPayme nt="">N</partII>
</coverageOption>
<tripName>Europ ean Tour</tripName>
<enrollmentFee> 5.00</enrollmentFee>
<totalPayment>7 65.00</totalPayment>
<tripDates departureDate=" 5/14/2007" returnDate="5/17/2007" tripDays="4" />
<numofParticipa nt>3</numofParticipan t>
- <participants >
<participant firstName="Cind y" mInit="b" lastName="Rose"
birthdate="4/26/1955" tripCost="2500" partIPremium="1 87.50"
partIIPremium=" 25.00" />
<participant firstName="Kath y" mInit="c" lastName="Barlo w"
birthdate="6/28/1944" tripCost="2500" partIPremium="2 62.50"
partIIPremium=" 35.00" />
<participant firstName="Matt hrew" mInit="d" lastName="Kamin ski"
birthdate="4/27/1933" tripCost="2500" partIPremium="3 00.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="4057887 933">Y</homePhone>
<bizPhone>N</bizPhone>
</phone>
<enrollAgreemen t>Y</enrollAgreement >
- <payment>
<method>card</method>
<billingAddre ss name="Betty Sun" street="4406 larwin ct." city="Concord"
state="CA" province="" country="United States" />
<creditCard type="visa" number="4XXXXXX XXXXXXXX" expDate="7/2007" />
</payment>
</enrollment>

and My server program is like this:

Dim xmlDoc, InstreamXMLRoot , TestFlag

Set xmlDoc=Server.C reateObject("Mi crosoft.XMLDOM" )
xmlDoc.Load Request '--this is for xml sent via body

Response.Conten tType = "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.parseErr or.errorCode <0 Then
Call UpdateXMLRespon se(orderID, "False", "XML", "error code: "
&xmlDoc.parseEr ror.errorCode & " reason: " &xmlDoc.parseEr ror.reason &" line
#: " &xmlDoc.parseEr ror.line , "")
End If

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

END IF

Set InstreamXMLRoot =xmlDoc.documen tElement
IF isNULL(Instream XMLRoot) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Ser ver.MapPath("B2 BResponse/" & hour(now) & "_" & minute(now) &
"_" & RandomNumber(10 00000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse. xml"))

--
Betty
Aug 23 '08 #1
10 15580
"c676228" <be***@newsgrou p.nospamwrote in message
news:40******** *************** ***********@mic rosoft.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=vbScri pt%>
<%
Set xmlDom=CreateOb ject("Microsoft .XMLDOM")
Use MSXML2.DOMDocum ent.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.Createob ject("MSXML2.Se rverXMLHTTP")
Belts and braces use MSXML2.ServerXM LHTTP.3.0
xmlhttp.Open "POST","htt ps://www.mydomain.co m/ac/xt_ac_B2B.asp", false

xmlhttp.setRequ estHeader "Content-Type",
"applicatio n/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.stat us <200) then
Response.Write( "The remote server returned an invalid statuscode:
#8221;"
& _
xmlHttp.status & " " & xmlHttp.statusT ext) & "<br>"
Response.Write( "response text from remote server" & _
" " & xmlHttp.respons eText)
Response.End
end if

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

Response.CharSe t = "UTF-8"
Response.Write xmlhttp.respons exml.xml
This can really mess up the character encoding use instead:-

xmlhttp.respons eXML.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="200808 251114527143" PONumber="50000 "
marketingCode=" E" productName="ad ventureCenter">
<test>Y</test>
<residency>US </residency>
- <coverageOption >
<partI totalPartIPayme nt="12.55">Y</partI>
<partII totalPartIPayme nt="">N</partII>
</coverageOption>
<tripName>Europ ean Tour</tripName>
<enrollmentFee> 5.00</enrollmentFee>
<totalPayment>7 65.00</totalPayment>
<tripDates departureDate=" 5/14/2007" returnDate="5/17/2007" tripDays="4"
/>
<numofParticipa nt>3</numofParticipan t>
- <participants >
<participant firstName="Cind y" mInit="b" lastName="Rose"
birthdate="4/26/1955" tripCost="2500" partIPremium="1 87.50"
partIIPremium=" 25.00" />
<participant firstName="Kath y" mInit="c" lastName="Barlo w"
birthdate="6/28/1944" tripCost="2500" partIPremium="2 62.50"
partIIPremium=" 35.00" />
<participant firstName="Matt hrew" mInit="d" lastName="Kamin ski"
birthdate="4/27/1933" tripCost="2500" partIPremium="3 00.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="4057887 933">Y</homePhone>
<bizPhone>N</bizPhone>
</phone>
<enrollAgreemen t>Y</enrollAgreement >
- <payment>
<method>card</method>
<billingAddre ss name="Betty Sun" street="4406 larwin ct." city="Concord"
state="CA" province="" country="United States" />
<creditCard type="visa" number="4XXXXXX XXXXXXXX" expDate="7/2007" />
</payment>
</enrollment>

and My server program is like this:

Dim xmlDoc, InstreamXMLRoot , TestFlag

Set xmlDoc=Server.C reateObject("Mi crosoft.XMLDOM" )
Again use MSXML2.DOMDocum ent.3.0

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

Response.Conten tType = "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.parseErr or.errorCode <0 Then
Call UpdateXMLRespon se(orderID, "False", "XML", "error code: "
&xmlDoc.parseEr ror.errorCode & " reason: " &xmlDoc.parseEr ror.reason &"
line
#: " &xmlDoc.parseEr ror.line , "")
End If

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

END IF

Set InstreamXMLRoot =xmlDoc.documen tElement
IF isNULL(Instream XMLRoot) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Ser ver.MapPath("B2 BResponse/" & hour(now) & "_" & minute(now)
&
"_" & RandomNumber(10 00000) & "_" & 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.Conten tType = "text/xml" ' Yes move this line to where you send the
response
Response.CharSe t = "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

"c676228" wrote:
and 05272008ACTest. xml file is like this:
- <enrollment orderID="200808 251114527143" PONumber="50000 "
marketingCode=" E" productName="ad ventureCenter">
<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="windo ws-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
"Old Pedant" <Ol*******@disc ussions.microso ft.comwrote in message
news:7B******** *************** ***********@mic rosoft.com...
>
"c676228" wrote:
and 05272008ACTest. xml file is like this:
- <enrollment orderID="200808 251114527143" PONumber="50000 "
marketingCode=" E" productName="ad ventureCenter">
<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="windo ws-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
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>Fals e</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>Fals e</isSuccess>
<errorField>XML </errorField>
<errorMessage>e rror 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*******@disc ussions.microso ft.comwrote in message
news:7B******** *************** ***********@mic rosoft.com...

"c676228" wrote:
and 05272008ACTest. xml file is like this:
- <enrollment orderID="200808 251114527143" PONumber="50000 "
marketingCode=" E" productName="ad ventureCenter">
<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="windo ws-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


"c676228" <be***@newsgrou p.nospamwrote in message
news:9E******** *************** ***********@mic rosoft.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>Fals e</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>Fals e</isSuccess>
<errorField>XML </errorField>
<errorMessage>e rror 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
"c676228" <be***@newsgrou p.nospamwrote in message
news:40******** *************** ***********@mic rosoft.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.C reateObject("Mi crosoft.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.Conten tType = "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
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="200808 251114527143" PONumber="50000 " marketingCode=" E"
productName="ad ventureCenter">
</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="200808 251114527143" PONumber="50000 " marketingCode=" E"
productName="ad ventureCenter">
<test>Y</test>
</enrollment>

Only one extra line: <test>Y</testbesides the top element.
Now it complains again:
<xmlResponse>
<isSuccess>Fals e</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.C reateObject("MS XML2.DOMDocumen t.3.0") '8/23/2008
xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body

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

If xmlDoc.parseErr or.errorCode <0 Then
Call UpdateXMLRespon se(orderID, "False", "XML", "error code: "
&xmlDoc.parseEr ror.errorCode & " reason: " &xmlDoc.parseEr ror.reason &" line
#: " &xmlDoc.parseEr ror.line , "")
End If

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

END IF

Set InstreamXMLRoot =xmlDoc.documen tElement
IF isNULL(Instream XMLRoot) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Ser ver.MapPath("B2 BResponse/" & hour(now) & "_" & minute(now) &
"_" & RandomNumber(10 00000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse. xml"))
'check if this is production transaction
Call UpdateXMLRespon se(orderID, "False", "XML", "The server received the XML
stream", "")
'************** *************** *************** *************** **
' Update B2B Response ''Response.Cont entType="text/xml"
'************** *************** *************** *************** **
Function UpdateXMLRespon se(byVal order_id, byVal SuccFlag, byVal ErrField,
byVal Desc, byVal PolicyNum)
'Set RespInfo=Server .CreateObject(" Microsoft.XMLDO M")
Set RespInfo=Create Object("MSXML2. DOMDocument.3.0 ")
RespInfo.async= False
RespInfo.load(s erver.MapPath("/Utility/B2BResponse.xml "))
Set RespInfoRoot=Re spInfo.document Element
Set SuccessNode=Res pInfoRoot.selec tSingleNode("is Success")
SuccessNode.Tex t=SuccFlag
If SuccFlag="True" Then
Set PolicyNode=Resp InfoRoot.select SingleNode("pol icyNumber")
PolicyNode.Text =PolicyNum
Else
Set ErrNode=RespInf oRoot.selectSin gleNode("errorF ield")
ErrNode.Text=Er rField
Set DescNode=RespIn foRoot.selectSi ngleNode("error Message")
DescNode.Text=D esc
End If

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

<%
Response.Conten tType = "text/xml"
Response.Write RespInfo.xml
Set RespInfo=Nothin g
Response.End

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

'************** ********
Client side program is like this:
'************** ********
<%@ Language=vbScri pt%>
<%
'Set xmlDom=CreateOb ject("Microsoft .XMLDOM")
set xmlDom=CreateOb ject("MSXML2.DO MDocument.3.0")

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

dim xmlhttp
set xmlhttp=server. CreateObject("M SXML2.ServerXML HTTP.3.0") '8/23/2008

xmlhttp.Open
"POST","htt ps://www.travelinsur anceservices.co m/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.stat us <200) then
Response.Write( "The remote server returned an invalid statuscode: #8221;"
& _
xmlHttp.status & " " & xmlHttp.statusT ext) & "<br>"
Response.Write( "response text from remote server" & _
" " & xmlHttp.respons eText)
Response.End
end if

if xmlHttp.respons eXML is nothing then
Response.Write( "The remote server didn’t return xml content.")
Response.End
end if
Response.Conten tType = "text/xml"
Response.CharSe t = "UTF-8"
'Response.Write xmlhttp.respons exml.xml
xmlhttp.respons eXML.save Response
Set xmlhttp = nothing
%>
--
Betty
"Anthony Jones" wrote:
"c676228" <be***@newsgrou p.nospamwrote in message
news:40******** *************** ***********@mic rosoft.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.C reateObject("Mi crosoft.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.Conten tType = "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
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.
/08232008adventu reServerHttp.as p, line 13

line 12 and 13 are:
12: xmlhttp.Open
"POST","htt p://www.travelinsur anceservices.co m/ac/xt_ac_B2B.asp", false
13: xmlhttp.send xmlDom '8/23/2008
--
Betty
"Anthony Jones" wrote:
>

"c676228" <be***@newsgrou p.nospamwrote in message
news:9E******** *************** ***********@mic rosoft.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>Fals e</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>Fals e</isSuccess>
<errorField>XML </errorField>
<errorMessage>e rror 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
"c676228" <be***@newsgrou p.nospamwrote in message
news:F2******** *************** ***********@mic rosoft.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="200808 251114527143" PONumber="50000 "
marketingCode=" E"
productName="ad ventureCenter">
</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="200808 251114527143" PONumber="50000 "
marketingCode=" E"
productName="ad ventureCenter">
<test>Y</test>
</enrollment>

Only one extra line: <test>Y</testbesides the top element.
Now it complains again:
<xmlResponse>
<isSuccess>Fals e</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.C reateObject("MS XML2.DOMDocumen t.3.0") '8/23/2008
xmlDoc.async = false
xmlDoc.Load Request '--this is for xml sent via body

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

If xmlDoc.parseErr or.errorCode <0 Then
Call UpdateXMLRespon se(orderID, "False", "XML", "error code: "
&xmlDoc.parseEr ror.errorCode & " reason: " &xmlDoc.parseEr ror.reason &"
line
#: " &xmlDoc.parseEr ror.line , "")
End If

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

END IF

Set InstreamXMLRoot =xmlDoc.documen tElement
IF isNULL(Instream XMLRoot) Then
Set InstreamXMLRoot =Nothing
Call UpdateXMLRespon se(orderID, "False", "XML", "The server didn't receive
the XML stream", "")

END IF
'Save all info before any transaction
xmlDoc.Save(Ser ver.MapPath("B2 BResponse/" & hour(now) & "_" & minute(now)
&
"_" & RandomNumber(10 00000) & "_" & month(now) & "_" & day(now) & "_" &
year(now) &"_B2BResponse. xml"))
'check if this is production transaction
Call UpdateXMLRespon se(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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1684
by: Honza Pazdziora | last post by:
Hello, I'm processing documents that can have any element names in them. The only restriction is placed on the attributes of these elements, each of them can only have two attributes of given names. I'd like to validate this input. I can specify this requirement using xsd:any for /root element, like: <xsd:element name="root">
5
21195
by: PhiSYS | last post by:
I want to know what's wrong with this code (I'm an amateur programmer). I'm trying to check if every field has a value or if checkboxes/radios have at least one item checked on each group (yes, you know, with the same name in the HTML tag). I want to have a generic code which I can fit to every document. The problem is that it never got into the line: if(elm.type == "checkbox" || elm.type == "radio") I've put an alert(elm.type)
8
1663
by: Adrienne | last post by:
The elements MENU and DIR were in the HTML 2.0 spec, and disappeared in 4. I would like to have them back, they makes sense. For example: <menu> <li>Home</li> <li>Contact</li> </menu> Perhaps speech enabled user agents could react accordingly, perhaps say
1
6865
by: juli jul | last post by:
Hello , I am trying to write to xml document (c#) by this code: XmlTextWriter xml_writer=null; xml_writer=new XmlTextWriter("Database.xml",null); xml_writer.WriteStartDocument(); xml_writer.WriteStartElement("", "Account", ""); The problem is that when I am trying to open the xml I see there such an error (instead of the normal xml doc):
0
890
by: Markchivs | last post by:
Hi all I have some .NET cod ethat is doing a simple serialization of an object. However the resulting string XML now has a root documentelement of the type name rather than the element name I expected. Here's an example: <ApplicationType> .... </ApplicationType> instead of the XSD defined:
2
11321
by: nico | last post by:
The following example returns a string type, but I need a tuple... <type 'str'> I need that for a method parameter. Thx
5
2966
by: SuneR | last post by:
Hi, I am having problems figuring out how to make Firefox behave, and output the HTML I want it to output. The thing I want done is actually quite simple. I have a <labeltag, and inside it, I have a script tag, that document.write's some HTML. Like this:
7
2543
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I'm trying to use the W3C Markup Validator to validate my HTML and I'm getting some errors: document type does not allow element "div" here; missing one of "button", "map", "object", "ins", "del", "noscript" start-tag <li ><a href="/" title=""><div>Home</div></a></li> Apparently I'm not allowed to put a block-level element, like div or table, inside an inline element, like span, or a. I tried moving the div tags to the outside of...
1
5074
by: Daniel Matias | last post by:
Vector v = new Vector(); Vector n = new Vector(); System.out.print(" "); w = input.nextInt();//this is for receiving the width System.out.print(" "); h = input.nextInt();//this is for receiving the height v.addElement(w); n.addElement(h);
0
8911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8760
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6015
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2673
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.