473,385 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Forward XML request

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
2 4936

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark Watkins | last post by:
suppose I have the following: -----------BEGIN page1.asp---------- <form method="post" action="page2.asp"> <select name="someData" size="1" class="smallbutton"> <option...
3
by: jrefactors | last post by:
page0.asp->page1.jsp When the user click submit button in page0.asp, it will post the form request to page1.jsp. page0.asp and page1.jsp are in separate machines. In page1.jsp, based on the...
1
by: jjouett | last post by:
I'm setting up a manually created WSDL file that defines the specifics of the required elements, default values, etc. instead of using the generated WSDL from the asmx?wsdl mechanism. Everything...
4
by: John | last post by:
Hi everybody, for my web-application (it must currently work only under IE6) I have a servlet that intercepts user's HTTP GET requests for a typical search result page, which contains a paging...
0
by: nielsena54 | last post by:
I am currently working on a client-server project using WCF. I have been using .NET for about 3 months now and have some questions about what it can do and how to do it. Before the question, here...
1
by: thallasridevi | last post by:
Hi All, I have page called page1.php with some hidden fields and i submitted the page to page2.php. I page2.php, i am able to get the values of hidden fields through $_REQUEST. And from this page...
5
dmjpro
by: dmjpro | last post by:
Could anyone tell me what is difference between jsp:forward and RequestDispatcher.forward? These two codes behave differently ... <jsp:forward page="page_ref"/> and
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.