SoapDocumentMethodAttribute.OneWay Property
Gets or sets whether an XML Web service client waits for the Web server to finish processing an XML Web service method.
[Visual Basic] Public Property OneWay As Boolean [C#] public bool OneWay {get; set;} [C++] public: __property bool get_OneWay(); public: __property void set_OneWay(bool); [JScript] public function get OneWay() : Boolean; public function set OneWay(Boolean);
Property Value
true if the XML Web service client does not wait for the Web server to completely process an XML Web service method. The default value is false.
Remarks
When an XML Web service method has the OneWay property set to true, the XML Web service client does not have to wait for the Web server to finish processing the XML Web service method. As soon as the Web server has deserialized the SoapServerMessage, but before invoking the XML Web service method, the server returns an HTTP 202 status code. A HTTP 202 status code indicates to the client that the Web server has started processing the message. Therefore, an XML Web service client receives no acknowledgment that the Web server successfully processed the message.
One-way methods cannot have a return value or any out parameters.
If you are using the .NET Framework version 1.0 XML Web service methods that have either the SoapRpcMethodAttribute or SoapDocumentMethodAttribute attribute applied to them with the OneWay property of set to true, do not have access to their HttpContext using the static Current property. To access the HttpContext, derive the class implementing the XML Web service method from WebService and access the Context property.
Example
[Visual Basic, C#] The following code example is an XML Web service method that does not require the client to wait for the XML Web service method to complete. Therefore, the sample sets the OneWay property to true.
[Visual Basic] <%@ 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 [C#] <%@ 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. } }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
SoapDocumentMethodAttribute Class | SoapDocumentMethodAttribute Members | System.Web.Services.Protocols Namespace | SoapServerMessage