简体   繁体   English

如何从 ASP 中的 HTTP 请求中获取 XML

[英]How to get XML out of HTTP Request in ASP

I'm trying to post an XML page in Android with HTTP POST to an ASP-page.我正在尝试在 Android 中将 XML 页面与 HTTP POST 一起发布到 ASP 页面。 My problem now is that I'm not really a ASP-programmer, but I need this page in ASP.我现在的问题是我不是一个真正的 ASP 程序员,但我需要 ASP 中的这个页面。 Can someone help me on track to get the XML out of the HTTP Post and into my ASP, so I can save the XML-file on my server?有人可以帮助我将 XML 从 HTTP 发布到我的 ASP 中,这样我就可以将 XML 文件保存在我的服务器上吗? Thank you very much.非常感谢。

In Android, I'm going to put my XML in a StringBuilder, following this example.在 Android 中,我将按照此示例将我的 XML 放入 StringBuilder 中。

StringBuilder sb = new StringBuilder();

sb.append("<ArrayOfString>");
sb.append("<string>").sb.append("the_command").sb.append("</string>");
sb.append("</ArrayOfString>");

StringEntity entity = new StringEntity(sb.toString(), "UTF-8");
httppost.setEntity(entity);  
httppost.addHeader("Accept", "application/xml");
httppost.addHeader("Content-Type", "application/xml");

HttpResponse response = httpclient.execute(httppost); 

In my ASP-page looks like this for the moment在我的 ASP 页面中,暂时看起来像这样

<%
strFilenaam = "d:\myhrm\android\xml\" & day(now) & month(now) & year(now) & hour(now) & minute(now) & second(now)
set oFs = server.createobject("Scripting.FileSystemObject")

blnOk = oFs.fileExists(strFilenaam & intTeller & "httppost.xml")
Do While blnOk = True
intTeller = intTeller + 1
blnOk = oFs.fileExists(strFilenaam & intTeller & "httppost.xml")
Loop
set oTextFile = oFs.OpenTextFile(strFilenaam & intTeller & "httppost.xml", 2, True)

oTextFile.Write "Test"
oTextFile.Close
set oTextFile = nothing
set oFS = nothing

Response.Write("OK")
%>

setEntity sets your request body in plain text (in this case the XML data). setEntity 将您的请求正文设置为纯文本(在本例中为 XML 数据)。 Usually you need key-value pairs that you can read via the Request.Form collection.通常您需要可以通过 Request.Form 集合读取的键值对。 You might want to try the Request.BinaryRead method in this case.在这种情况下,您可能想尝试 Request.BinaryRead 方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM