通过查询字符串将xml传递给Classic ASP表单

时间:2010-08-16 20:29:07

标签: xml asp-classic query-string xmlhttprequest

我有一个测试表单(见下文),如果我手动提交,(单击“提交”按钮),则会从操作脚本中返回XML列表。

我希望能够通过xmlHTTP传递当前包含在测试HTML表单中的XML。到目前为止没有运气。任何帮助,将不胜感激。

<form action="processorders.asp" method="post" name="Orders" target="_blank">
    <textarea cols="80" rows="10" name="request">
     <REQUEST Version="1.0">
         <RequestID>06012005171718</RequestID>
         <Command>Orders</Command>
         <UserID>myuserID</UserID>
         <Password>xyzuvw</Password>
         <Status>all</Status>
         <SecurityKey></SecurityKey>
         <OrderStartNumber>2255</OrderStartNumber>         
      </REQUEST>
   </textarea><br>
    <input type="submit">
</form>

1 个答案:

答案 0 :(得分:1)

未经测试,但您可以尝试这样的事情:

Dim objXMLHTTP, returncode, XMLstring
XMLstring =  "<REQUEST Version=""1.0"">"
XMLstring = XMLstring & "<RequestID>06012005171718</RequestID>"
XMLstring = XMLstring & "<Command>Orders</Command>"
XMLstring = XMLstring & "<UserID>myuserID</UserID>"
XMLstring = XMLstring & "<Password>xyzuvw</Password>"
XMLstring = XMLstring & "<Status>all</Status>"
XMLstring = XMLstring & "<SecurityKey></SecurityKey>"
XMLstring = XMLstring & "<OrderStartNumber>2255</OrderStartNumber>"
XMLstring = XMLstring & "</REQUEST>"
' Create an xmlhttp object:
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
' Open the connection to the remote server:
objXMLHTTPOpen "POST", "http://url.to.your/target", False
objXMLHTTP.Send cstr(XMLstring)
' Actually Sends the request and returns the data:
returncode = objXMLHTTP.responseText
Set objXMLHTTP = Nothing
' Now do with the returncode what you like (this is the response HTML form the target URL)

请注意: - 您通过不安全的HTTP线路发送用户名和密码数据 - XML未经过验证或解析,您可能需要通过XML解析器

运行它

Rico Suave