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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass an XML DOM object to an ASP Page from VB

Status
Not open for further replies.

Jjackstraw

Programmer
Apr 17, 2001
8
US
I am working on an application that will make limited use of IIS. Management has placed a restriction that no web forms may be used to allow users to input data. So I have a bunch of data collected from the client VB App that I need to pass to the Server to be passed to an ASP page which will return a report the User can view to a VB internet control. My first thought was XML. I created an ASP page to process the XML document and a VB page to create the document, but I can't figure out how to pass an XML document to an ASP page then display that page on an internet control on a VB form.
I have an XMLDOM object that contains the document, but when I use the xmlHTTP method .send I can't display the page on the next VB form. Any Ideas?




-John Geoghan
Consultant
York, PA
 
make use of the response object in your asp page to write the xml you want to display in your control back to you.

try organising data flow like this

vbclient -> post xml to asp -> asp updates server -> asp uses response.write to return confirmation to vbclient ->vbclient receives confirmation in xmlhttprequest.responsexml ->display confirmation somewhere.
 
thank-you pflangan.
I am having problems implementing the data flow. It is the vbclient -> post xml to asp step that I can't figure out.
I am currently calling the navigate2 method to show the ASP page in the control on the VB form then immediately calling a post to show the second ASP page in the control, but I have to save the XML document on the server to do this (I would prefer to send it to the page in a stream). What I really need to know is a way to send the XML from the VB app to the first ASP page so that page will have state in the VB control. I tried to send it in a Session variable, but I couldn't start a Session in VB then mantain it when I navigated to the ASP page on the VB web-control.
Any more ideas?

-John Geoghan
Consultant
York, PA
 
I'd use an msxml.xmlhttprequest object. here's a bit of code that might be of help. This function takes a string containing a path to an xml file, and the url to post that file to. if it succeeds, the function returns 0, otherwise it returns -1.

You also need to create the listener.asp page on the server where you want to send this file. all you do there is load either the recordset, or xml file from the request object. if everything works ok, then write an ok string back to the response object. easypeesyjapaneesy

private function SendToServer(strFileName As String, strURL As String) As Integer
'Author: Paul Langan. 10/05/2001. pf_langanATyahooDOTcom
'This function takes an xmlfile, and posts the contents of that file to a remote asp page

Dim objHTTPRequest As MSXML.XMLHTTPRequest
Dim oDoc As MSXML.DOMDocument
Dim objReceiveXMLDOM As New MSXML.DOMFreeThreadedDocument '
Dim objXMLNode As MSXML.IXMLDOMNode
Set oDoc = New MSXML.DOMDocument
On Error GoTo err_label

'load the xml file. this could also be an existing domdoc

oDoc.Load (strFileName)
Set objHTTPRequest = New MSXML.XMLHTTPRequest

'open the url eg:

With objHTTPRequest
.Open "POST", strURL, False
.send oDoc 'send the xml document
End With

'if you need verification, or some xml back again use the .responseText property


With objReceiveXMLDOM
.async = False
.loadXML objHTTPRequest.responseText
'in my page, if everything went ok, i pass a simple response node back to the calling environment
Set objXMLNode = .selectSingleNode("response")
End With

Select Case objXMLNode.Text
Case "OK"
msgbox " sent OK"
SendToWebServer = 0
Case Else
msgbox " error not processed"
SendToWebServer = -1
End Select

Set objXMLNode = Nothing
Set objReceiveXMLDOM = Nothing
Set objHTTPRequest = Nothing
Set oDoc = Nothing

exit_label:
Exit Function

err_label:
msgbox "ERROR: " & Err.Number & " Desc: " & Err.Description
Resume exit_label
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top