p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP XML (http://p2p.wrox.com/forumdisplay.php?f=69)
-   -   Reading XML datastream returned from vendor (http://p2p.wrox.com/showthread.php?t=3579)

marabunta September 7th, 2003 12:34 PM

Reading XML datastream returned from vendor
 
I am sending the information from a form to a vendor site. There's a hidden field on the form that is loaded with the well-formed xml when the submit button is clicked. This is then passed to a vendor web site to get a quote. Their system reads this xml from the hidden field (via request.form) and passes pure xml code as the result (with a response.write). There is no other way to communicate with their system except to use their form handler since among other hidden fields are mandatory default fields that rae used to login etc.

My question is this ... how can I capture this XML returned from the form handler so that I can reformat it properly for display?. The returned XML shows up in my browser window but I can't seem to find a way to get to it.

When I use their url directly as the form handler (action=their url) I get the returned XML displayed in my browser ... If I try to replace their form handler with my own (see below)I get a blank page.

ANy help would be greatly appreciated.

I tried using setting the form action to an asp page. Within this asp page I grab all of the for elements and use the MSXML2.ServerXMLHTTP to send the request but it does not seem to be working.

content of the my asp form handler:

    for each sFormElement in Request.Form
         sDataToSend = sDataToSend & "&" & sFormElement & "=" & Server.HTMLEncode(Request.Form(sFormElement))
    next

    sDataToSend = Right(sDataToSend, Len(sDataToSend) - 1)

    strUrl = "https://www.vendor.com/xml/"
    strContentType = "application/x-www-form-urlencoded"

    set oXMLHttp = server.Createobject("MSXML2.ServerXMLHTTP")

    Call oXMLHttp.Open("POST", strURL, false)
    Call oXMLHttp.setRequestHeader("Content-Type", strContentType)
    Call oXMLHttp.Send(sDataToSend)


    set oResponseXMLDom = oXMLHttp.ResponseXML



planoie September 8th, 2003 09:23 AM

It sounds like the form is posting directly to their system. As you'll never be able to get control of the return XML. What you'll need to do is have the form post to your server, then you need to construct your own web request as a form post that your server will make to their server. Then your server will receive the response and process the returning XML as needed.

Look into the System.Net.HttpWebRequest class. I have only used this a little, but with it you should be able to construct a complete web request, building the form elements that you received from the user's form post, point it to their page, and a class method will return the response stream to you so you can grab the XML. It's going to turn your server into the browser from the viewpoint of your vendor's site.

Good luck,
Peter


All times are GMT -4. The time now is 12:30 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.