A one-way contract is a methods invoke operations on a Windows Communication Foundation (WCF) service from a client but do not expect a reply. This type of contract can be used, for example, to publish notifications to many subscribers. You can also use one-way contracts when creating a duplex (two-way) contract, which allows clients and servers to communicate with each other independently so that either can initiate calls to the other. This can allow, in particular, the server to make one-way calls to the client that the client can treat as events.
Steps to create a one-way contract
- Create the service contract by applying the ServiceContractAttribute class to the interface that defines the methods the service is to implement.
- Indicate which methods in the interface a client can invoked by applying the OperationContractAttribute class to them.
- Designate operations that must have no output (no return value and no out or ref parameters) as one-way by setting the IsOneWay property to true. Note that the operations that carry the OperationContractAttribute class satisfy a request-reply contract by default because the IsOneWay property is false by default. So you must explicitly specify the value of the attribute property to be true if you want a one-way contract for the method.