收到 HTTP 包含的发布请求 XML

我需要配置一个侦听文档的网页 XML 通过消息 HTTP. 我不需要 POST, 我需要得到它 POST. 它是什么? 我应该使用处理程序 HTTP, 网络服务, webRequest, 流或其他东西? 我需要使用服务器 IIS 而且更喜欢 C#.

我试过了。

..

我不认为我可以使用 WebRequest, 因为我没有发送请求,但我只是等他们。

"HttpRequest.InputStream", 但我不确定如何使用它或在哪里放置它。 是否需要使用Web服务或应用程序使用它 asp.net? 我把它放了
http://forums.asp.net/t/1371873.aspx/1

我尝试了一个简单的Web服务
http://msdn.microsoft.com/en-u ... .aspx
- 但是当我想去的时候 "http://localhost:8000/EchoWithGet?s=Hello, world!", 我得到了 "webpage cannot be found error"

如果有人有任何有用的代码或链接,那将是伟大的!

EDIT:
我正在尝试从另一个程序接收通知。
已邀请:

知食

赞同来自:

您可以编写应用程序 ASP.NET, 你张贴了哪个 IIS, 您可以在其中有一个页面 .ASPX, 或一个常见的处理程序 .ASHX /根据您想要格式化结果的不同 - 你想回来吗? HTML 或其他一些类型/, 然后读
Request.InputStream

, 这将包含来自客户的请求正文。

这是如何编写通用处理程序的示例 /
MyHandler.ashx

/:


public class MyHandler : IHttpHandler
{
public void ProcessRequest/HttpContext context/
{
var stream = context.Request.InputStream;
byte[] buffer = new byte[stream.Length];
stream.Read/buffer, 0, buffer.Length/;
string xml = Encoding.UTF8.GetString/buffer/;

... do something with the XML

// We only set the HTTP status code to 202 indicating to the
// client that the request has been accepted for processing
// but we leave an empty response body
context.Response.StatusCode = 202;
}

public bool IsReusable
{
get
{
return false;
}
}
}

涵秋

赞同来自:

我不知道在哪里打电话或使用处理程序。 这就是我到目前为止的...

Default.aspx


<%@Page Inherits="WebApplication1._Default"%>
<%@OutputCache Duration="10" Location="Server" varybyparam="none"%>
<script language="C#" runat="server">
void Page_Init/object sender, EventArgs args/ {

}
}
</script>
<html>
<body>
</body>
</html>


Default.aspx.cs


namespace WebApplication1 
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load/object sender, EventArgs e/
{
HttpContext contex = Context;
MyHandler temp = new MyHandler//;
temp.ProcessRequest/context/;
}
}

public class MyHandler : IHttpHandler
{
public void ProcessRequest/HttpContext context/
{
var stream = context.Request.InputStream;
byte[] buffer = new byte[stream.Length];
stream.Read/buffer, 0, buffer.Length/;
string xml = Encoding.UTF8.GetString/buffer/;

... do something with the XML

// We only set the HTTP status code to 202 indicating to the
// client that the request has been accepted for processing
// but we leave an empty response body
context.Response.StatusCode = 202;
}

public bool IsReusable
{
get
{
return false;
}
}
}
}

要回复问题请先登录注册