Forward XML request

B

Bingo

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 !
 
A

Anthony Jones

Bingo said:
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
 
B

Bingo

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 :
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top