惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
M
MIT News - Artificial intelligence
D
Docker
S
SegmentFault 最新的问题
B
Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
U
Unit 42
C
Check Point Blog
GbyAI
GbyAI
美团技术团队
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
Google Developers Blog

博客园 - mahope

一个算法题解 在ASP.NET web 站点中使用log4net (1.2.9) 在.NET 中实现 AOP 解决Web Service中传递子类实例时,序列化的问题。 openwave:Malformed server response web 项目的 csproj 文件要有对应的.webinfo文件才能在vs里面打开 - mahope 软件需求规范(SRS)指南 写需求文档的一般原则 删除everyone对c:的 访问权限后,运行asp.net出现DirectoryNotFoundException未找到路径“C:\”的一部分 - mahope - 博客园 NHibernate Mapping文件中如何指定类的字节数组属性 NHibernate.ADOException : Unable to perform find 对于事件不能调用BeginInvoke,可改用另外一层包装 IBM面试题试解(关于50条狗、50个人、病狗) Einstein's Riddle 爱因斯坦出的智力题? Artificial intelligence: Solving problems for the real world 一些面向对象的设计法则 重构、分支语句、虚函数、抽象函数与多态--《重构:改善既有代码设计》之读书心得 NHibernate 执行内嵌类(Nested Class)查询 为内嵌类(Nested Class)配置NHibernate的O/R Mapping文件
Q & A:Does ASP.NET support one-way Web Service operations?
mahope · 2006-03-25 · via 博客园 - mahope

Q Does ASP.NET support one-way Web Service operations?

A Yes, you can implement one-way operations in ASP.NET by setting the OneWay property of the SoapDocumentMethod attribute to true, as shown here:

[WebMethod]
[SoapDocumentMethod(OneWay
=true)]
public void DoSomeWork(string someInfo, string someMoreInfo)
{
    
// do some real work here
    System.Threading.Thread.Sleep(5000);
}

Of course, one-way operations cannot have return values by definition (a SOAP fault is generated if you execute a one-way operation that returns something). By definition, a one-way operation has an input message and no output message, as illustrated by the WSDL generated from this .asmx endpoint:

•••
<portType name="OneWayServiceSoap">
   
<operation name="DoSomeWork">
      
<input message="s0:DoSomeWorkSoapIn" />
   
</operation>
</portType>
•••

As soon as ASP.NET finishes deserializing the SOAP message and before it invokes the method, it sends an HTTP response of "202 Accepted" back to the client, indicating it has started processing the request. The client doesn't have to wait for the server to finish processing the request, but the cost is that it won't know the final outcome.

If you invoke this WebMethod using the .asmx-generated HTML test form (not using SOAP), you'll see it wait five seconds before displaying the result. But if you invoke it using the following SOAP message and using an HTTP POST utility (like post.js) as shown in the following code

C:>post http://localhost/oneway/service1.asmx -h 
SOAPAction "urn:example-org:oneway/DoSomeWork" -
Content
-Type "text/xml" -f req.xml

it will return immediately, which truly illustrates the nature of a OneWay request:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  
<soap:Body>
    
<DoSomeWork xmlns="urn:example-org:oneway">
      
<someInfo>string</someInfo>
      
<someMoreInfo>string</someMoreInfo>
    
</DoSomeWork>
  
</soap:Body>
</soap:Envelope>