Monday, August 9, 2010

Service Contracts and Service Types

Service Contracts and Service Types:


The ServiceContractAttribute, defined in the System.ServiceModel namespace, can be applied to either .NET interfaces or .NET classes. It is used to declare the type as a Service contract.

The Service Contract attribute enables the WCF runtime to generate a description for the service.

The ServiceContractAttribute can be declared without any parameters, but it can also take named parameters.

Name: Specifies a different name for the contract instead of the default, which is simply the interface or class type name. This contract name is what will appear in the portType name when consumers access the WSDL.

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

Eg:

[ServiceContract(Name="MathService")]
public interface IService1
{
}

No comments: