SoapDocumentMethodAttribute.OneWay 属性

获取或设置 XML Web services 客户端是否等待 Web 服务器完成对 XML Web services 方法的处理。

**命名空间:**System.Web.Services.Protocols
**程序集:**System.Web.Services(在 system.web.services.dll 中)

语法

声明
Public Property OneWay As Boolean
用法
Dim instance As SoapDocumentMethodAttribute
Dim value As Boolean

value = instance.OneWay

instance.OneWay = value
public bool OneWay { get; set; }
public:
property bool OneWay {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_OneWay ()

/** @property */
public void set_OneWay (boolean value)
public function get OneWay () : boolean

public function set OneWay (value : boolean)

属性值

如果 XML Web services 客户端不等待 Web 服务器完全处理 XML Web services 方法,则为 true。默认值为 false

备注

当 XML Web services 方法将 OneWay 属性设置为 true 时,XML Web services 客户端无需等待 Web 服务器完成对 XML Web services 方法的处理。一旦 Web 服务器已经反序列化 SoapServerMessage 后,则在调用 XML Web services 方法之前,服务器返回 HTTP 202 状态代码。HTTP 202 状态代码向客户端指示 Web 服务器已开始处理消息。因此,XML Web services 客户端接收不到 Web 服务器已成功处理消息的确认。

单向方法不能具有返回值或任何输出参数。

如果您使用的是 .NET Framework 1.0 版的 XML Web services 方法,而该方法应用了 OneWay 属性设置为 trueSoapRpcMethodAttributeSoapDocumentMethodAttribute 属性 (Attribute),那么请不要使用静态 Current 属性 (Property) 访问它们的 HttpContext。若要访问 HttpContext,请从 WebService 派生实现 XML Web services 方法的类,并访问 Context 属性。

示例

下面的代码示例是一个不要求客户端等待 XML Web services 方法完成的 XML Web services 方法。因此,该示例将 OneWay 属性设置为 true

<%@ WebService Language="VB" Class="Stats" %>
 
Imports System.Web.Services
Imports System.Web.Services.Protocols

Public Class Stats
    Inherits WebService
        
    <SoapDocumentMethod(OneWay := True), _
    WebMethod(Description := "Starts nightly statistics batch process.")> _
    Public Sub _
        StartStatsCrunch()
        
        ' Begin nightly statistics crunching process.
        ' A one-way method cannot have return values.
    End Sub
End Class
<%@ WebService Language="C#" Class="Stats" %>
 
 using System.Web.Services;
 using System.Web.Services.Protocols;
 
 public class Stats: WebService {
 
      [ SoapDocumentMethod(OneWay=true) ]
      [ WebMethod(Description="Starts nightly statistics batch process.") ]
      public void StartStatsCrunch() {
         // Begin nightly statistics crunching process.
         // A one-way method cannot have return values.
      }      
 
 }

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

SoapDocumentMethodAttribute 类
SoapDocumentMethodAttribute 成员
System.Web.Services.Protocols 命名空间
SoapServerMessage