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.

CHAPTER 11 ■ WORKING WITH DATA 357ramrameshreddy.blog.com}[DataMember(Name = "AverageVolume")]internal decimal AvgVol;[DataMember(Name = "MarketCapital")]internal double MarketCap;[DataMember(Name = "PriceEarningRatio")]internal decimal PERatio;[DataMember(Name = "EarningsPerShare")]internal decimal EPS;[DataMember(Name = "52WkHigh")]internal decimal FiftyTwoWeekHigh;[DataMember(Name = "52WkLow")]internal decimal FiftyTwoWeekLow;Using the Message ClassUp until now you have been looking at the various serialization techniques and data transferarchitectures available to use as part of WCF. Understanding this basic foundation and howdata transfers within WCF is key. In looking at data transfers, it is important to understand thecore foundation of WCF—the Message class.As stated earlier, the Message class is one of the two pillars of WCF and serves as a generalpurposecontainer of data for all communication between a service and the consumers of thatservice. However, you should use it only in a few specific scenarios. For example, you shoulduse it if you need either an alternative way of handling an incoming message or an alternativeway of creating the outgoing message (say, saving the message to disk). The Message class isclosely aligned to the SOAP protocol and contains a header and body. The Message class isdefined in the System.ServiceModel.Channels namespace, and you create a simple message bycalling the CreateMessage static method on the factory. Listing 11-13 shows a sample operationcontract using Message.Listing 11-13. Message Class in Operations[ServiceContract()]public interface IQuickReturnStock{[OperationContract]System.ServiceModel.Channels.Message GetCurrentTicker();}ramrameshreddyramrameshreddy[OperationContract]void SetTickerSymbol(System.ServiceModel.Channels.Message data);

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

Saved successfully!

Ooh no, something went wrong!