Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2005, 11:38 AM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Server to Server XML Problem (ASP.NET to ASP)

Hi;
I'm sending an XML file from an ASP.NET application on one server to an ASP page on another server, and (for the life of me), can't figure out why my XMLDOM.documentElement is always null.

------------------------------
Here's the XML file I send:
------------------------------

<?xml version="1.0" encoding="utf-8" ?>
<Notice>
  <LastName>Smith</LastName>
  <FirstName>Robert</FirstName>
</Notice>


------------------------------
Here's the ASP.NET code that sends the file
(this is in the handler of a button on an ASP.NET page)
------------------------------
        'Send XML document to receving ASP page and print result
        Dim xmlPath As String = Server.MapPath("test.xml")
        Dim xmlHTTP As Object = Server.CreateObject("MSXML2.ServerXMLHTTP")
        Dim xmlDoc As Object = Server.CreateObject("MSXML2.DOMDocument")

        'Load xml doc
        xmlDoc.load(xmlPath

        'Set method, url, async
        xmlHTTP.open("POST", "http://www.test.com/ImportXML.asp", False)

        'Send XML document
        xmlHTTP.send()

        'Display the result
        lblMsg.Text = xmlHTTP.responseText

-------------------------------------------------
Here's the ASP page that receives the XML
-------------------------------------------------
<%
dim xmldoc

Set xmldoc = Server.CreateObject("Msxml2.DomDocument.3.0")
xmldoc.async = False
xmldoc.load(Request)

If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   Response.Write "<Error>" & myErr.reason & "</Error>"
End If

Response.write xmlDoc.documentElement.firstChild.nodeName
%>

-----------------------
Question:
-----------------------
Why do I always get the following error (why is my documentElement always Null/Nothing?

Microsoft VBScript runtime error '800a01a8'

Object required: '[object]'

/ODN/ImportXMLNotice.asp, line 15
 
Old February 2nd, 2005, 01:22 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

When you send the document you are not sending anything:
Code:
xmlHTTP.send()
=>
Code:
xmlHTTP.send(xmlDoc)


--

Joe (Microsoft MVP - XML)
 
Old February 2nd, 2005, 02:17 PM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe;
Thanks for the second pair of eyes. I corrected my code, got all excited, and realized I'd inched forward to the next mystery.

Whether I do either
   xmlHTTP.send(xmlDoc) or
   xmlHTTP.send(xmlDoc.xml)
the result is the same.

I continually get "XML document must have a top level element." returned by the ASP page that is receiving the XML.

You can see the XML that I'm sending (below, in the original post), and, does it not have a single, root, top-level element? ("Notice")?

Am I missing something obvious at the ASP end?

Thanks,
Tim
 
Old February 3rd, 2005, 06:15 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Try setting async property to false, it may not have finished loading:
Code:
Dim xmlDoc As Object = Server.CreateObject("MSXML2.DOMDocument30")
xmlDoc.async = false
'Load xml doc 
xmlDoc.load(xmlPath)
Why are you using COM interop in .NET, there are some issues with this for xml documents, use the .NET native classes.

--

Joe (Microsoft MVP - XML)
 
Old February 3rd, 2005, 12:36 PM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again, Joe.
Thanks again for your second suggestion. It has, unfortunately, not made a difference.

I will, as you suggest, try the native .NET classes for this transfer, and post my results back here.

Can you, however, suggest how I can verify (echo) the actual Request being received by the ASP page?

Thanks,
Tim
 
Old February 3rd, 2005, 04:14 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It maybe that the encoding is not that stated in the prolog.
Try using loadXML on the string:
Code:
<Notice>
  <LastName>Smith</LastName> 
  <FirstName>Robert</FirstName> 
</Notice>
and see if that works. If it does your document is encoded as something other that utf-8 or the account in which the page is running doesn't have permission to read the file.

--

Joe (Microsoft MVP - XML)
 
Old February 4th, 2005, 10:02 AM
Registered User
 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe.
Thanks again for the suggestions. At least one worked!

I used

xmlDoc.LoadXML("<?xml version=""1.0"" encoding=""utf-8"" ?><Response>Okay</Response>")

and it the ASP page correctly returned back the contents of xmlDoc.xml.

So, perhaps you're right - there is an encoding problem with the XML stream being received by the Request object of the ASP page. I will investigate further.

If trying the .NET classes for sending the XML (instead of the Com InterOp classes, then I'll resort to just "uploading" the file to the ASP server, passing the filename in the call to the ASP page, and have the ASP page to load the file. It seems a little silly to have to resort to this approach, though.

I'll report back here what I discover over the next little while.
Thanks,
Tim
 
Old April 26th, 2006, 03:22 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kosta
Default

hi all, im also having trouble getting asp.net VB to send a xml document to a server and recieve a response.

the server i need to send the xml document is also CGI based. My question is can i use these differnet platform and genereate and response even though im using asp.net from cgi?

i've tried combining my code using the system.xml

Dim xmlHTTP As Object = Server.CreateObject("MSXML2.ServerXMLHTTP")
Dim XmlDocument As New XmlDocument()
XmlDocument.Load("c:\XMLFile.xml")
Dim xmlfile As String = XmlDocument.InnerXml
xmlHTTP.open("POST", "http://xmltest.res99.com/xml/xps.cgi", False)

''Send XML document
xmlHTTP.send(xmlfile)

''Display the result
lblmsg.Text = xmlHTTP.responseText

i've combined the asp and asp.net classes together i think.
using this the cgi server still spit out saying the xml document is missing?

i just cant find the asp.net method to send the actuall xml document using asp.net.

any help will ge great
thankyou
kosta





kosta Koder





Similar Threads
Thread Thread Starter Forum Replies Last Post
Xml from SQL Server into ASP.NET toddw607 ASP.NET 2.0 Basics 4 June 4th, 2007 08:57 AM
Creating Dynamic ASP.NET Server Controls Using XML kwilliams XSLT 0 October 6th, 2006 01:42 PM
problem 2 connecting SQL Server 200 using ASP.NET nagen111 ADO.NET 5 February 16th, 2005 01:26 AM
Asp.Net Server Controls Overlapping Problem vinod_pawar1 General .NET 1 August 15th, 2004 06:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.