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.com354 CHAPTER 11 ■ WORKING WITH DATAramrameshreddy.blog.comspecific ordering of elements the same as in a data contract. The only difference when comparedto the data contract is the inheritance scenario. Unlike the data contract, in a messagecontract the base type’s members are not sorted before the child type’s members.If you need to implement a SOAP action, then you need to define that with the serviceoperation of the service contract through the [OperationContract] attribute. To specify theSOAP action, you need to set the Action and ReplyAction properties on the [OperationContract]attribute when defining the service operation. The SOAP specification allows the three attributeslisted in Table 11-2 in the header. By default, these headers are not emitted, but they can be setvia the Actor, MustUnderstand, and Relay properties on the [MessageHeader] attribute, respectively.Note, if you have the property MustUnderstand set to true and you have a new version ofthe message contract, then you will get an exception at runtime because there is an extra headerin the SOAP message that is “not understood.”Table 11-2. Valid SOAP Header AttributesValueActor (version 1.1)/Role (version 1.2)MustUnderstandRelayDescriptionHeader’s target URISpecifies whether the node processing the header mustunderstand it or notSpecifies whether the header can be relayed downstreamto other nodesAt times a service might be required to support legacy XML. This is especially true in integrationand interop situations where the platforms might differ between the consumer andthe service. If required, you can enable the legacy XML encoding by setting the Use propertyon the [XmlSerializerFormat] attribute to Encoded, as shown in Listing 11-11. However, this isnot recommended for two reasons. First, arrays are not supported, and second, it’s becauseobject references are preserved within the message body.Listing 11-11. QuickReturnStockQuote Using Legacy SOAP Encoding[XmlSerializerFormat(Use=OperationFormatUse.Encoded)]public class QuickReturnStockQuote{[DataMember(Name = "TickerSymbol")]public string Symbol;}[DataMember]public string CompanyName;ramrameshreddyramrameshreddy[DataMember]public decimal LastTrade;//Abbreviated for Clarity

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

Saved successfully!

Ooh no, something went wrong!