ProtectionLevel
The default value for ProtectionLevel is None or the value which is set at
ServiceContract level. It defines the Protection Level of operation and how
service messages will be protected. The value for ProtectionLevel can be set
as
- None : No protection will be applied to messages and message will flow on wire as plain text.
- Sign : Messages will be digitally signed before sending.
- EncryptAndSign : Messages will be encrypted before sign and sending.
Not all
wcf Bindings like BasicHttpBindins supports ProtectionLevel. For using
ProtectionLevel property you must use the binding which supports protection.
Bindings security mode should be set to Message, if it is set to None or
Transport the operation level setting of protection level does not have any
effect.
[ServiceContract()]
public interface IOrders
{
[OperationContract(ProtectionLevel =
ProtectionLevel.Sign)]
int GetHighValueOrdersCount(DateTime
dt);
}
AsyncPattern
AsyncPattern is a Boolean property
with default value of false. You can mark it as true if your service operation
should execute asynchronously on client or server or both. You should create
the asynchronous operations to handle long running processes like I/O calls.
For creating wcf asynchronous
operations use the method name conventions as BeginMethodName and
EndMethodName. The BeginMethodName must be marked as
[OperationContract(AsyncPattern=true)].
[ServiceContract]
public interface IOrders
{
[OperationContract]
int TodaysOrderCount(DateTime dt);
[OperationContract(AsyncPattern =
true)]
IAsyncResult BeginPlaceOrder(Order
order, AsyncCallback cb, Object state);
bool EndPlaceOrder(IAsyncResult ar);
}
Action
and ReplyAction
Action and ReplyAction properties
are co related. The default value for Action is concatenation of
ServiceNameSpace + ServiceContractName + OperationName and for ReplyAction
ServiceNameSpace + ServiceContractName + OperationName + Response.
Action header indicates the URI of
Operation to be invoked and defines WS-Addressing action. WS-Addressing allows
you transport neutral communication between client and service and it is very
much useful in situation where SOAP response is not enough and cannot be
provided immediately. So you will have to introduce intermediate router service
between client and target service which will receive message and route to
different services for additional activities.
You can specify the value for Action
and ReplyAction as "*" (an asterisk) to handle all unhandled URI.
[ServiceContract(Namespace="http://orders.northwind.com")]
public interface IOrders
{
[OperationContract(
Action="http://orders.northwind.com/placeorders",
Name="PlaceOrders",
ReplyAction="http://orders.northwind.com/reorderqty"
)]
Message PlaceOrders(Message msg);
}
HasProtectionLevel
HasProtectionLevel is a read only Boolean property with default value of false. If value of ProtectionLevel is set to "None" it will return false and if ProtectionLevel is set to Sign or EncryptAndSign it will return true.
Name
It is read/write string property.
You can get or set the different and meaningful name to your operations using
this property. The default value for this property would be your method name.
The value of this property will be used in wsdl for <operation> element.
[ServiceContract()]
public interface IOrders
{
[OperationContract(Name="PlaceOrder")]
bool OrderPlace(Order order);
}
Message PlaceOrders(Message msg);
}
IsInitiating
IsInitiating is a Boolean property
with default value of false. The service operation marked with IsInitiating =
true must be called before any other operation from client side. This operation
will create new session for client. For use of this the ServiceContract should support sessions by
marking SessionMode=SessionMode.Required or SessionMode=SessionMode.Allowed.
This property can be used where Service Contract needs to validate the client
details before executing any operation.
From below example client must call
ValidateClient before any other operation call. If any other operation get
called before ValidateClient service returns ActionNotSupported FaultException. Operation PlaceOrder can be call
many times after calling ValidateClient and before CloseChannel.
No comments:
Post a Comment