Query ASP to GET XML via HTTP Post URGENT HELP PLEASE

Discussion in 'XML' started by Aliandro, Feb 1, 2005.

  1. Aliandro

    Aliandro Guest

    Hi I am really stuck and need some expertise help please.
    I have an XML file:
    <XML>
    <USER_INFO>
    <USERNAME>username</USERNAME>
    <PASSWORD>password%</PASSWORD>
    </USER_INFO>
    <SITE_INFO>
    <SITE_NO>18856</SITE_NO>
    </SITE_INFO>
    </XML>

    I am trying to use HTTP Post to send the above XML to an ASP page, this is
    the code I am using to send the XML to the ASP Page.
    <html>
    <head>
    <script type="text/javascript">
    function getPage()
    {
    var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
    objHTTP.Open('POST','http://websitetoxmlgateway/xmlgateway.asp',false,'username','password%')
    //gateway where the ASP page is
    objHTTP.Send("http://mywebsite/note.xml") //my xml file
    document.all['A1'].innerText= objHTTP.status
    document.all['A2'].innerText= objHTTP.statusText
    document.all['A3'].innerText= objHTTP.responseText
    document.all['A4'].innerText= objHTTP.responseXML
    document.all['A5'].innerText= objHTTP.responseXML.nodeName;
    }
    </script>
    </head>

    <body onload="getPage()">
    <h2>Using the HttpRequest Object</h2>

    <p>
    <b>status:</b>
    <span ID="A1"></span>
    </p>

    <p>
    <b>status text:</b>
    <span ID="A2"></span>
    </p>

    <p>
    <b>response:</b>
    <br><span ID="A3"></span>
    </p>

    <p>
    <b>response2:</b>
    <br><span ID="A4"></span>
    </p>
    <p>
    <b>response3:</b>
    <br><span ID="A5"></span>
    </p>
    </body>
    </html>

    When I do the Post and run the above file on my server it tells me the
    following Error Message.
    <XMLRESPONSE><ERRORS><ERROR><COMPONENT>RX_RMS</COMPONENT><INTERFACE>IGateway</INTERFACE><METHOD>Execute</METHOD><TEXT>"USERNAME"
    node missing or empty [2]</TEXT><DATETIME>02 Feb 2005
    08:40:03</DATETIME></ERROR></ERRORS></XMLRESPONSE>

    Any help is appreciated. Thanks for your time.
    Ali
     
    Aliandro, Feb 1, 2005
    #1
    1. Advertising

  2. Aliandro wrote:

    > Hi I am really stuck and need some expertise help please.
    > I have an XML file:
    > <XML>
    > <USER_INFO>
    > <USERNAME>username</USERNAME>
    > <PASSWORD>password%</PASSWORD>
    > </USER_INFO>
    > <SITE_INFO>
    > <SITE_NO>18856</SITE_NO>
    > </SITE_INFO>
    > </XML>
    >
    > I am trying to use HTTP Post to send the above XML to an ASP page, this is
    > the code I am using to send the XML to the ASP Page.
    > <html>
    > <head>
    > <script type="text/javascript">
    > function getPage()
    > {
    > var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
    > objHTTP.Open('POST','http://websitetoxmlgateway/xmlgateway.asp',false,'username','password%')
    > //gateway where the ASP page is
    > objHTTP.Send("http://mywebsite/note.xml") //my xml file


    I think the send method wants you to pass in a document itself as an
    object or the XML as a string but what you have simply sends the string
    with the URL. So try
    var xmlDocument = new ActiveXObject('Microsoft.XMLDOM');
    xmlDocument.async = false;
    xmlDocument.load('http://mywebsite/note.xml');
    objHTTP.send(xmlDocument);
    for a start but take note that all that synchronous loading might be
    easier for a quick test but in the end you should change to asynchronous
    loading to not block the browser while XML is loaded/parsed respectively
    sent.

    In general script in a HTML page loaded via HTTP can only connect back
    to the server the page comes from so I wonder whether those attempts
    simply fail as you are trying to load XML from or POST XML to another
    server.
    So it is crucial if you have further problems that you tell us exactly
    how you load that HTML page with the script, is that loaded from the
    local file system (e.g. file: URL)? Then at least you would have a
    chance to connect to different servers.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 2, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vishal
    Replies:
    1
    Views:
    675
    Steve C. Orr [MVP, MCSD]
    Dec 21, 2004
  2. Ron Peleg, Creo
    Replies:
    2
    Views:
    774
    Ron Peleg, Creo
    Feb 13, 2006
  3. rup
    Replies:
    10
    Views:
    711
    CBFalconer
    Jan 7, 2007
  4. Matt
    Replies:
    5
    Views:
    396
    Aaron Bertrand - MVP
    May 4, 2004
  5. Fred
    Replies:
    17
    Views:
    258
Loading...

Share This Page