Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

Namespace:  System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)
public bool OneWay { get; set; }

Property Value

Type: System.Boolean
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.

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.

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.

<%@ 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.
      }      

 }

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.