Introduction: One-way operations in WCF Services.
One-way operations is is all about an operation
which have not any returned values. Sometimes, Client does not care about
success and failure of the calling of any operations, In this type of cases, WCF
offers one-way operations. Once the client issues the call, WCF generates a
request message, but no reply message will return to the client.As a result,
One-way operations does not return any values.
When the client callls a one-way method, it should not be called for a moment
that means one way call do not support asynchronous calls.
Configure one-way Operations:
The OperationContract attribute offers the Boolean IsOneWay property. Here, we use 'b' as IsOneWay property as shown in the code below:
Code:
<AttributeUsage(AttributeTargets.Method)>
_
Public
NotInheritable Class
OperationContractAttribute
Inherits
Attribute
Public
Property b() As
Boolean
Get
Return m_b
End Get
Set(value
As Boolean)
m_b = Value
End Set
End Property
Private m_b
As Boolean
End Class
By default, the value of IsOneWay property is
false which means it is a request-reply operations. We have a need to change
IsOneWay property to true for making it One nway operation.
<ServiceContract()>
_
Interface
IMyService1
<OperationContract(b:=True)>
_
Sub Mymethod()
End Interface
Public
Class MyService1
Implements IMyService1
Public Sub
Mymethod()
Return
"hello"
End Sub
End
Class
Client Implementation Code:
MyService1 s1 = new MyService1();
s1.Mymethod();
Join the conversation! Your thoughts help the community grow.