11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

amrameshreddy.blog.com124 CHAPTER 4 ■ INSTALLING AND CREATING WCF SERVICESramrameshreddy.blog.comTable 4-6. OperationContractAttribute PropertiesClass PropertyActionAsyncPatternIsInitiatingIsOneWayIsTerminatingNameReplyActionDescriptionControls the action on the request (input) message; the default is thecontract namespace, contract name, and operation name. Use this inconjunction with * to indicate the operation can handle all unmatchedoperation requests—there can be only one of these, and it must take amessage as a parameter.Provides for the implementation of an asynchronous process on the server,client, or both tiers. This feature aids .NET clients in supporting operationswith the efficiency of using a single client thread.Indicates that this operation is an initiation of a session; the default is true,so if you require session initiation, you need to set all operations to falseexcept the initiation operation.Indicates that the operation returns nothing (void) or can’t accept outparameters. The default is false; as a result, all operations without it returnan empty message that is useful for capturing exceptions. If applying thevalue of true to an operation that is marked with a return type other thanvoid, WCF doesn’t throw a compiler error. Instead, it throws anInvalidOperation exception when the WCF framework inspects theServiceContract types at runtime.Indicates this operation terminates the session and the channel should close.Overrides the operation name from the method name on the interface.Controls the action on the reply (output) message. Used in conjunction withthe Action property.The solution Example06 has an updated version of the ITradeService service contract. Inthis version, the OperationContract properties have been explicitly set. You’ll also notice thatthe ServiceContract attribute now has a new property indicating it supports sessions.Without the ServiceContract.SessionMode property being set to SessionMode.Required, theOperationContract properties of IsInitiating and IsTerminating would be illogical. Thiscondition is not caught at compile time, only at reflection time.Listing 4-10 is a snippet from Example06. Notice that some added properties have been setin both the ServiceContract and OperationContract attribute initialization.Listing 4-10. TradeService.cs with OperationContract Properties[ServiceContract(Namespace = "http://PracticalWcf",Name = "TradeService",SessionMode = SessionMode.Required)]public interface ITradeService{[OperationContract(Action="http://PracticalWcf/TradeSecurityNow",IsOneWay = false,ramrameshreddyramrameshreddy

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!