Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML to Form data, redirect to another page 1

Status
Not open for further replies.

teamBadMonkey

Programmer
Feb 3, 2005
9
US
I was wondering if someone could help me out...

I have an existing ASP file that uses Request.Form() data extensively. I'm writing an intermediate file because I need to tie in the ability to receive external XML data (via POST), parse it, then tie it to Form data objects so that the existing code can use it.

I've tried setting up a form that self-submits (using a img onLoad() to call some JavaScript that does a myForm.submit() - yeah i know, ugly), but all that returns is the text of that page - it doesn't actually follow the action of the form to the target file.

if i use request.form() after i've parsed the xml, I get ''Cannot use the generic Request collection after calling BinaryRead.''

can anyone help?

-steve
 
hey monkey hope this helps usually with binary reads on XML files anytime a binary read error occurs is when you try to call the binary call before the request object (simple yet it happens a lot) what I would do is
Code:
set usr = server.CreateObject ("members.UserObjects.1")
set specs = Server.CreateObject("MSXML2.DOMDOCUMENT.3.0")
specs.load(Request)

so you can create the object and then say load the request for it whne it's needed. Hope this helps.
 
it's not working the way i expected....

** incoming xml stream **
Code:
<?xml version="1.0">
<root>
   <userID>xxxx</userID>
</root>

the XML is posted to example.asp
** example.asp **
Code:
' parse incoming XML
set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async=false
objXML.load(request)

Set objUserName = objXML.getElementsByTagName("userId")

<form method=POST name=MainForm action=target.asp>
   <input type=hidden name=myData value=<%=objUserName.item(0).text%>>
   <script language="javascript" runat="server">
     document.MainForm.submit();
   </script>
</form>

** target.asp **
Code:
<%
response.write request("myData")
%>

i would expect to see the result of target.asp printed, however, i see the HTML of the form from example.asp:
Code:
<form method=POST name=MainForm action=target.asp>
   <input type=hidden name=myData value=xxxx>
</form>
any ideas on a better implementation? well, maybe not just better, rather, one that works like i want it too? :)

-steve
 
I'm not clear on your submission process. you have the files laid out in one order above but it seems they are somehow executing in another...or youi have some vital HTTP code you left out? Otherwise i couldn't see you could possibly get the source code from example.asp as the printed result in target.asp...

I have a two file example of a similar process using POSTd XML, but unfortunatly it is on the home machine and would have to wait until I left work (not a long enough lunch break left ot on-the-fly write up a couple of exmaples :p)

-T

barcode_1.gif
 
that's the thing - it is never getting to target.asp. the HTML from example.asp is what's being returned to the calling site.

i need the form to execute at the server and return the result of target.asp.

unless, of course, there's another way to get this done. :)
 
Oooh. I see.

First problem is that you have a javascript error, your trying to submit the form, but thats a client-side action :) So instead it just returns the form to your caller (XMLHTTP object?) instead of doing a magical redirection to the third page in the middle :)

If it were me I would say just bundle everything in the XML and let it all fly :)

One option might be to look into some of the pure ASP file upload scripts. The better ones handle both binary file data and standard form input data. While I'm not sure any would work out of the box in this situation you would be able to alter one, I would think.

The absolute easiet method (besides embedding all your data in the XML :) ) would be to toss the other input values into the querystring :) Even if it becomes in accessible you can always push it into a string first or even access it from the ServerVariables collection.

-T

barcode_1.gif
 
What I ended up doing was requiring the site to POST the data to me (instead of XML, I was getting goofy BinaryRead errors), and I included my example.asp script in the target.asp script.

target.asp:
Code:
if request.querystring("externalSite") = 1 then
  ' example.asp now just does data validation
%>
  <!-- #include FILE="example.asp" -->
<%
end if

response.write request("myData")

That works. I wish I understood what other options I had, but for now, I guess I'm happy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top