且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

需要编写HTTP服务器,我可以使用带有“NOSOAP”的Web服务吗?

更新时间:2023-02-03 11:36:42

好吧,你可以发布到ashx;很容易设置 - 只需从请求中读取

并写入响应...


Marc
Well, you could just post to an ashx; pretty easy to setup - simply read
from the Request and write to the Response...

Marc

>



" Marc Gravell" <毫安********** @ gmail.com> skrev i en meddelelse

新闻:O3 ************** @ TK2MSFTNGP04.phx.gbl ...

"Marc Gravell" <ma**********@gmail.com> skrev i en meddelelse
news:O3**************@TK2MSFTNGP04.phx.gbl...
嗯,你可以刚刚发布到ashx;非常容易设置 - 只需从请求中读取
并写入响应......

Marc
Well, you could just post to an ashx; pretty easy to setup - simply read
from the Request and write to the Response...

Marc




这听起来很棒!


您能否提供更多关于此处的信息!



This sounds great!

Can you give more info on where to read about this!


最简单的事情就是创建一个新的(空的) )网站,添加一个ashx(通用

处理程序),然后玩它;例如(写,不读 - 但很容易

使用Load和Request.InputStream)见下文。请注意,对于大的
xml(在Mb范围内),您可能希望避免使用XmlDocument类,因为它具有性能(主要是内存)开销。使用XmlReader / XmlWriter远远超过
更高效,但也(更)更难以正确使用。对于小到中等大小的xml,XmlDocument很好

,另外它给你XPath / XQuery。


希望这有帮助,
>
Marc


<%@ WebHandler Language =" C#"类= QUOT;处理程序&QUOT; %>


使用System;

使用System.Web;


公共类处理程序:IHttpHandler {


public void ProcessRequest(HttpContext context){

context.Response.ContentType =" text / xml&quot ;;

系统。 Xml.XmlDocument doc = new System.Xml.XmlDocument();

doc.LoadXml(@"< Test Of ="" Some"">< Xml /> < / Test>");

doc.Save(context.Response.OutputStream);

}


public bool IsReusable {

get {

返回false;

}

}


}
Easiest thing is just to create a new (empty) web-site, add an ashx (generic
handler), and play with it; for example (writes, doesn''t read - but easy to
do using Load and the Request.InputStream) see below. Note that for large
xml (in the Mb range) you may wish to avoid the XmlDocument class, as it has
a performance (mainly memory) overhead; using XmlReader / XmlWriter is far
more efficient, but also (much) trickier to get right. XmlDocument is fine
for small to mid-size xml, plus it gives you XPath / XQuery.

Hope this helps,

Marc

<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;

public class Handler : IHttpHandler {

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/xml";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(@"<Test Of=""Some""><Xml/></Test>");
doc.Save(context.Response.OutputStream);
}

public bool IsReusable {
get {
return false;
}
}

}