Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 July 12th, 2006, 12:11 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML Post From VB to asp page

Hi Everyone,

  Hopefully one of you will be able to instruct this ASP newbie on where I'm going wrong.

  I am attempting to post some XML text from VB6 to ans asp page and use the asp page to save the XML to a file.

  The asp page reports a zero length string, implying that my post is not successful.

  IIS3 (I think) in running on a W2K server.

  VB6 Code:

    Dim newXML As String
    Dim Q As String
    Q = Chr(34)

    newXML = newXML & "<?xml version=" & Q & "1.0" & Q & "?>" & vbCrLf
    newXML = newXML & "<collection_result>" & vbCrLf
    newXML = newXML & "<data>" & vbCrLf
    newXML = newXML & "DataTest" & vbCrLf
    newXML = newXML & "</data>" & vbCrLf
    newXML = newXML & "</collection_result>" & vbCrLf

    Dim ie As SHDocVw.InternetExplorer
    Set ie = New SHDocVw.InternetExplorer
    ie.Visible = True
    ie.Navigate "http://webserver/Lance/ReceiveResults.asp", , , newXML
    Set ie = Nothing


  ASP Code: (returns zero length oXML.xml)

    This code seems to be having a problem receiving the XML from the VB post! Results.txt is empty.


    <% @LANGUAGE = VBScript %>
    <%
    Response.ContentType = "text/xml"

    Set oXML = Server.CreateObject("Msxml2.DOMDocument")
    oXML.setProperty "ServerHTTPRequest", True
    oXML.async = False
    oXML.load(Request)

    oXML.save "e:\inetpub\wwwroot\lance\Results.txt"

    %>

  ASP Code: (Testing Msxml2 Dom Object)

    This code displays the XML and saves it to the Results.txt file.


    <% @LANGUAGE = VBScript %>
    <%
    Response.ContentType = "text/xml"

    Set oXML = Server.CreateObject("Msxml2.DOMDocument")
    oXML.async = False
    oXML.load("e:\inetpub\wwwroot\lance\test.xml")

    oXML.save "e:\inetpub\wwwroot\lance\Results.txt"
    response.write oXML.xml
    response.end

    %>


  Any help would be greatly appreciated. Thanks, Lance

 
Old July 12th, 2006, 04:24 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I figured it out....


  This VB6 code will launch an Internet Explorer window and display the results of the asp page you designate.

  Converting the PostData to a Byte array seemed to be the problem!

  This requires a reference to: Microsoft Internet Controls

    Dim ie As SHDocVw.InternetExplorer
    Set ie = New SHDocVw.InternetExplorer

    Dim URL As String
    Dim Flags As Long
    Dim TargetFrame As String
    Dim PostData() As Byte
    Dim Headers As String

    Dim newXML As String
    Dim Q As String
    Q = Chr(34)
    newXML = newXML & "<?xml version=" & Q & "1.0" & Q & "?>"
    newXML = newXML & "<collection_result>"
    newXML = newXML & "<data>"
    newXML = newXML & "DataTest"
    newXML = newXML & "</data>"
    newXML = newXML & "</collection_result>"

    URL = "http://webserver/Lance/ReceiveResults.asp"
    Flags = 0
    TargetFrame = ""
    PostData = StrConv(newXML, vbFromUnicode)

    ie.Visible = True
    ie.Navigate URL, Flags, TargetFrame, PostData, Headers

    Set id = Nothing


  To post without an Internet Explorer window...
  This requires a reference to: Microsoft XML... (whichever version you have???)

    Dim objXMLHTTP As MSXML2.XMLHTTP
    Set objXMLHTTP = New MSXML2.XMLHTTP

    Dim newXML As String
    Dim Q As String
    Q = Chr(34)
    newXML = newXML & "<?xml version=" & Q & "1.0" & Q & "?>"
    newXML = newXML & "<collection_result>"
    newXML = newXML & "<data>"
    newXML = newXML & "DataTest"
    newXML = newXML & "</data>"
    newXML = newXML & "</collection_result>"

    objXMLHTTP.open "post", "http://webserver/Lance/ReceiveResults.asp", False
    objXMLHTTP.send newXML

    '*** The following line will display the results!! ***
    'MsgBox objXMLHTTP.responseText

    Set objXMLHTTP = Nothing


 
Old July 13th, 2006, 08:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

trivial tip really, but you don't need that Q=Chr(34). If you want " inside a string just double it up like this:
Code:
newXML = newXML & "<?xml version=""1.0""?>"





Similar Threads
Thread Thread Starter Forum Replies Last Post
post xml using xmlhttp in vb.net datakix Classic ASP XML 4 August 7th, 2009 05:31 AM
How do I post a XML file to an URL using VB? chengjianjin Visual Basic 2005 Basics 3 April 28th, 2008 05:24 AM
Reading an XML post in an ASP.NET web site spudgun2005 ASP.NET 1.0 and 1.1 Basics 0 November 3rd, 2005 05:40 PM
How to post the date to another page ASP.NET? rpkarthic ASP.NET 1.x and 2.0 Application Design 1 August 12th, 2005 04:06 AM
post xml using xmlhttp in vb.net datakix VB.NET 3 December 21st, 2004 01:31 PM





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