Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Forward XML request

Reply
Thread Tools

Forward XML request

 
 
Bingo
Guest
Posts: n/a
 
      06-13-2006
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
 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      06-13-2006

"Bingo" <(E-Mail Removed)> wrote in message
news:u4dxN%(E-Mail Removed)...
> 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- 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




 
Reply With Quote
 
 
 
 
Bingo
Guest
Posts: n/a
 
      06-13-2006
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" <(E-Mail Removed)> wrote in message
> news:u4dxN%(E-Mail Removed)...
>> 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- 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

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
request.getRequestDispatcher(url).forward(request,response); problem jrefactors@hotmail.com Java 1 12-29-2004 05:13 AM
how to forward a request to a frame-based page in struts? vicky Java 0 06-08-2004 08:59 PM
Re-forward declaration of types which were already forward declared qazmlp C++ 1 02-15-2004 07:00 PM
disp.forward, then request.sendRedirect for Mac client problem Larry S Java 1 11-11-2003 07:44 PM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM



Advertisments