By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,727 Members | 766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,727 IT Pros & Developers. It's quick & easy.

Forward XML request

P: n/a
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
Jun 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Bingo" <Bi***@discussions.microsoft.com> wrote in message
news:u4****************@TK2MSFTNGP05.phx.gbl...
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


Jun 13 '06 #2

P: n/a
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" <Bi***@discussions.microsoft.com> wrote in message
news:u4****************@TK2MSFTNGP05.phx.gbl...
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


Jun 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.