Geeks With Blogs
Wes Fehler canadian geek

Define Service Contracts

Service Contract – mechanisms by which capabilities and requirements are specified for its consumers:

-          Interface/class

-          Operations within that type

-          3 core .NET attributes

o    ServiceContractAttribute

o    OperationContractAttribute

o    MessageParameterAttribute

ServiceContractAttribute

-          Can be applied to either Interfaces or clases

-          If the interface or class inherits from another Service Contract, you must explicitly use the ServiceContractAttirbute to declare the subtype as well

Named Parameter Options

·         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 <portType> element.

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

o    SessionMode.Allowed to specify that the service supports user session

o    SessionMode.Required to specify that the client must invoke the method within a session

·         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.

OperationContractAttribute

Apply the OperationContractAttribute to a method to indicate that the method implements a service operation as part of a service contract

Named Parameter Options

Use the OperationContractAttribute properties to control the structure of the operation and the values expressed in metadata:

·         The Action property specifies the action that uniquely identifies this operation. WCF dispatches request messages to methods based on their action.

·         The AsyncPattern property indicates that the operation is implemented or can be called asynchronously using a Begin/End method pair.

·         The HasProtectionLevel property indicates whether the ProtectionLevel property has been explicitly set.

·         The IsOneWay property indicates that the operation only consists of a single input message. The operation has no associated output message.

·         The IsInitiating property specifies whether this operation can be the initial operation in a session.  Default is true.  Set to false to ensure a client uses an existing instance.

·         The IsTerminating property specifies whether WCF attempts to terminate the current session after the operation completes.  Default is false.

·         The ProtectionLevel property specifies the message-level security that an operation requires at run time.

·         The ReplyAction property specifies the action of the reply message for the operation.

MessageParameterAttribute

The MessageParameterAttribute controls how the names of any operation parameters and return values appear in the service description.

FaultContractAttribute

When a service implementation throws a FaultException, the WCF plumbing thereafter takes care of serializing that back to the consumer as a SOAP fault as follows:

-          FaultException is used to send untyped fault data back to the consumer.

-          FaultException<TDetail> is used to send typed fault data back to the client.  Clients catching the exception can access the detailed fault information by getting it from the exception objects’ Detail property.

This attribute can be applied to operations only and cannot be inherited.  It can be applied multiple times for multiple types of faults.

Posted on Saturday, July 4, 2009 12:03 AM 70-503 , Study Notes | Back to top


Comments on this post: 70-503 Study Notes: Creating Services, Part I

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © wes | Powered by: GeeksWithBlogs.net