Pages

Men

rh

6/09/2012

What is Service Contract Attribute

What is Service Contract Attributes?
Service Contract Attributes defined in the System.ServiceModel namespace, can be applied to  .NET interface or  .NET Classes. It is used to declare the type as a service contract. This attributes are not inherited. So if the interface or class you are using to define your service contract inherits from another service contract, you must explicitly use the Service Contract Attributes to declare the subtype as a service contract as well.

Service contract attributes can be declared with out any parameters, but it can also take the named parameter.

Named Parameter :-
  • Name
  • Namespace
  • CallbackContract
  • Protectionlevel
  • Configuration Name
  • Session Mode
Name :-  
Specifies different name for the contract instead of the default, which is simply the interface or class type name. This contract name will appear in the port type name when the consumer access the WSDL.

Namespace:-
Specifies the target namespace in the WSDL for the service. The default name space is http:// tempuri.org

CallbackContract:-
Associates another service contract as a callback contract. This sets up the infrastructure for a duplex MEP and thereby allows the service to initiate sending message to the client. The Message exchange parameters section of this lesson discusses MEPs in more details.

ProtectionLevel:-
Enables the service contract to specify  constraints on how message to all operations in the contract are protected on the wire, that is, whether they are signed and encrypted.

Configuration Name:-
Specifies the name attribute of the service element in a configuration file. The default is the name of the service implementation class, that is service type.

SessionMode:-
it Specifies, whether session should be enabled by the endpoint by exposing this service contract.

A few points keep in the mind about usage of these parameter when you define your service contracr

Always use the Namespace property to provide a Uniform Resource Identifier
It is good practice to use the Namespace property to remove the  leading "I" because the  "I" prefix  is really more of  a .NET idiom than anything else.

Example :-

[ServiceContract (Name  = "TaskManagerService", Namespace - "http://schemas. fabrikam.com/2008/04/tasks/")]

public interface ITaskManagerService
{

}



No comments :

Post a Comment