Forward XML request

Discussion in 'ASP General' started by Bingo, Jun 13, 2006.

  1. Bingo

    Bingo Guest

    Hi group !

    I am trying to write an ASP page that would forward an XML request
    to a remote server, and then write the response to the client (a
    kind of proxy, if you like).

    I am sending the query to this ASP via a VBA (access2k) procedure,
    which basically looks like :

    Dim oXMLHTTP As New MSXML2.XMLHTTP40
    Const strURL As String = "http://myserver/myasppage.asp"
    Dim strResponse As String

    oXMLHTTP.Open "POST", strURL, False
    oXMLHTTP.Send "<?xml version=""1.0"" encoding
    =""iso-8859-1""?><xmlxmlxml/>"
    strResponse = oXMLHTTP.responseXML.xml



    Now, the problem I have is to retrieve this XML !
    In the ASP, I tried :

    strQuery = Request.BinaryRead(Request.TotalBytes)

    This kind of works but I retrieve an array of bytes, and this
    really not easy to convert to xml to be sent again.

    I tried with a form, but it didn't work at all :
    oXMLHTTP.SetRequestHeader "Content-Type",
    "application/x-www-form-urlencoded"
    oXMLHTTP.Send "queryxml=" & strQueryXML

    I did not retrieve anything in the ASP with
    Request.Form("queryxml")...

    Does anyone know of an easy solution for this ?

    Thanks a lot !
    --
    Arnaud Lesauvage
    Bingo, Jun 13, 2006
    #1
    1. Advertising

  2. "Bingo" <> wrote in message
    news:u4dxN%...
    > Hi group !
    >
    > I am trying to write an ASP page that would forward an XML request
    > to a remote server, and then write the response to the client (a
    > kind of proxy, if you like).
    >
    > I am sending the query to this ASP via a VBA (access2k) procedure,
    > which basically looks like :
    >
    > Dim oXMLHTTP As New MSXML2.XMLHTTP40
    > Const strURL As String = "http://myserver/myasppage.asp"
    > Dim strResponse As String
    >
    > oXMLHTTP.Open "POST", strURL, False
    > oXMLHTTP.Send "<?xml version=""1.0"" encoding
    > =""iso-8859-1""?><xmlxmlxml/>"


    You're passing send a Unicode string (which it will encode to UTF-8) but
    specifying an ISO-8859-1 encoding don't do that else things can get decoded
    incorrectly. You're probably better off not sending the XML declare at all.

    You're also sending XML as a string. You're better of building your XML in
    a DOM and passing the DOM to the send method (xmlhttp knows what to do with
    it) . BTW using DOM will cause the encoding to follow the encoding in the
    xml declare if you add one to the DOM and will add the appropriate text/xml
    content type header.


    > strResponse = oXMLHTTP.responseXML.xml
    >


    If it's returning XML and the xml is of use why are you retrieving the XML
    string.

    >
    >
    > Now, the problem I have is to retrieve this XML !
    > In the ASP, I tried :
    >
    > strQuery = Request.BinaryRead(Request.TotalBytes)
    >
    > This kind of works but I retrieve an array of bytes, and this
    > really not easy to convert to xml to be sent again.
    >
    > I tried with a form, but it didn't work at all :
    > oXMLHTTP.SetRequestHeader "Content-Type",
    > "application/x-www-form-urlencoded"
    > oXMLHTTP.Send "queryxml=" & strQueryXML
    >
    > I did not retrieve anything in the ASP with
    > Request.Form("queryxml")...
    >


    Now you really are getting lost.

    The big question is do you need to pre or post process this XML in this
    'middle-man' ASP page?

    I'll assume not :-

    Dim oXMLHTTP: Set oXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.x.0")
    'replace x with 3|4|6

    oXMLHTTP.open("POST", "otherURL", false)
    oXMLHTTP.setRequestHeader("Content-Type",
    Request.ServerVariables("CONTENT-TYPE"))
    oXMLHTTP.send Request ' Note .send can accept the Request object directly

    'send the result back raw

    Response.Status = oXMLHTTP.Status
    Response.ContentType = oXMLHTTP.getResponseHeader("Content-Type")
    Response.BinaryWrite oXMLHTTP.responseBody


    > Does anyone know of an easy solution for this ?
    >
    > Thanks a lot !
    > --
    > Arnaud Lesauvage
    Anthony Jones, Jun 13, 2006
    #2
    1. Advertising

  3. Bingo

    Bingo Guest

    Hi Anthony, thanks a lot for your answer !

    It is of great help !
    I still have some problems, but I'll ty to solve them on my own now !

    Anthony Jones a écrit :
    > "Bingo" <> wrote in message
    > news:u4dxN%...
    >> Hi group !
    >>
    >> I am trying to write an ASP page that would forward an XML request
    >> to a remote server, and then write the response to the client (a
    >> kind of proxy, if you like).
    >>
    >> I am sending the query to this ASP via a VBA (access2k) procedure,
    >> which basically looks like :
    >>
    >> Dim oXMLHTTP As New MSXML2.XMLHTTP40
    >> Const strURL As String = "http://myserver/myasppage.asp"
    >> Dim strResponse As String
    >>
    >> oXMLHTTP.Open "POST", strURL, False
    >> oXMLHTTP.Send "<?xml version=""1.0"" encoding
    >> =""iso-8859-1""?><xmlxmlxml/>"

    >
    > You're passing send a Unicode string (which it will encode to UTF-8) but
    > specifying an ISO-8859-1 encoding don't do that else things can get decoded
    > incorrectly. You're probably better off not sending the XML declare at all.
    >
    > You're also sending XML as a string. You're better of building your XML in
    > a DOM and passing the DOM to the send method (xmlhttp knows what to do with
    > it) . BTW using DOM will cause the encoding to follow the encoding in the
    > xml declare if you add one to the DOM and will add the appropriate text/xml
    > content type header.
    >
    >
    >> strResponse = oXMLHTTP.responseXML.xml
    >>

    >
    > If it's returning XML and the xml is of use why are you retrieving the XML
    > string.
    >
    >>
    >>
    >> Now, the problem I have is to retrieve this XML !
    >> In the ASP, I tried :
    >>
    >> strQuery = Request.BinaryRead(Request.TotalBytes)
    >>
    >> This kind of works but I retrieve an array of bytes, and this
    >> really not easy to convert to xml to be sent again.
    >>
    >> I tried with a form, but it didn't work at all :
    >> oXMLHTTP.SetRequestHeader "Content-Type",
    >> "application/x-www-form-urlencoded"
    >> oXMLHTTP.Send "queryxml=" & strQueryXML
    >>
    >> I did not retrieve anything in the ASP with
    >> Request.Form("queryxml")...
    >>

    >
    > Now you really are getting lost.
    >
    > The big question is do you need to pre or post process this XML in this
    > 'middle-man' ASP page?
    >
    > I'll assume not :-
    >
    > Dim oXMLHTTP: Set oXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.x.0")
    > 'replace x with 3|4|6
    >
    > oXMLHTTP.open("POST", "otherURL", false)
    > oXMLHTTP.setRequestHeader("Content-Type",
    > Request.ServerVariables("CONTENT-TYPE"))
    > oXMLHTTP.send Request ' Note .send can accept the Request object directly
    >
    > 'send the result back raw
    >
    > Response.Status = oXMLHTTP.Status
    > Response.ContentType = oXMLHTTP.getResponseHeader("Content-Type")
    > Response.BinaryWrite oXMLHTTP.responseBody
    >
    >
    >> Does anyone know of an easy solution for this ?
    >>
    >> Thanks a lot !
    >> --
    >> Arnaud Lesauvage

    >
    >
    >
    Bingo, Jun 13, 2006
    #3
    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. Brian Birtle
    Replies:
    2
    Views:
    1,992
    John Saunders
    Oct 16, 2003
  2. Larry S
    Replies:
    1
    Views:
    1,254
    Larry S
    Nov 11, 2003
  3. vicky
    Replies:
    0
    Views:
    749
    vicky
    Jun 8, 2004
  4. Replies:
    1
    Views:
    6,252
    Ryan Stewart
    Dec 29, 2004
  5. qazmlp
    Replies:
    1
    Views:
    585
    Jonathan Turkanis
    Feb 15, 2004
Loading...

Share This Page