ServiceContractAttribute Class

Base Namespace: System.ServiceModel

Indicates that an interface or a class defines a service contract in a Windows Communication Foundation (WCF) application.

An interface or class that is decorated with ServiceContractAttribute must also have at least one method marked with the OperationContractAttribute attribute to expose any functionality. See the Examples section for a code example of the simplest use of the two attributes to define and implement a service.
using System; using System.Collections.Generic; using System.Net.Security; using System.ServiceModel; using System.Text;  namespace Microsoft.WCF.Documentation {   [ServiceContract(     Namespace="http://microsoft.wcf.documentation",     Name="SampleService",     ProtectionLevel=ProtectionLevel.EncryptAndSign   )]   public interface ISampleService{     [OperationContract]     string SampleMethod(string msg);   }

Use the ServiceContractAttribute properties to modify the service contract.

  • The ConfigurationName property specifies the name of the service element in the configuration file to use.

  • The Name and Namespace properties control the name and namespace of the contract in the WSDL element.

  • The SessionMode property specifies whether the contract requires a binding that supports sessions.

  • The CallbackContract property specifies the return contract in a two-way (duplex) conversation.

  • The HasProtectionLevel and ProtectionLevel properties indicate whether all messages supporting the contract have a explicit ProtectionLevel value, and if so, what that level is.

Read Users' Comments (0)

0 Response to "ServiceContractAttribute Class"

Post a Comment