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 4 ■ INSTALLING AND CREATING WCF SERVICES 127ramrameshreddy.blog.comOperationBehavior AttributeThe other important behavior attribute is the OperationBehavior attribute. Although you havecontrol over the service-wide behaviors using the ServiceBehavior attribute, you have moregranular control at the operation level.Again, these are implementation details applied at the class method level instead of theservice interface. Operation aspects controllable through this attribute are as follows:Transactional: Provides for autocompletion along with transaction flow and the requiredand supported optionsCaller identity: When binding supports, provides the ability to execute under the caller’sidentityObject recycling: Provides for overriding the InstanceMode mode of theServiceContractBehaviorUnderstanding Data ContractsData contracts, in WCF, are the preferred method of abstracting your .NET types from theschema and XML serialized types. With WCF, you have choices for creating the metadata thatis used to publish your service and how that impacts the runtime serialization of your .NETtypes into platform-agnostic schema types that are represented in XML.The process is all hidden, if you choose, from the developer. Primitive types are easilymapped to leverage the default DataContractSerializer. Other types are controllable throughthe DataContract attribute capabilities. However, if you still want control, you can alwaysleverage XmlSerializer to manage the serialization of your types into XML. So, in the followingsections, we’ll first walk you through some of the ways you can work with XmlSerializerbefore moving on to data contracts.All the examples so far have leveraged the default DataContractSerializer type for XMLserialization/deserialization. You’ll take a brief look at levering XmlSerializer for managingthe XML serialization process.XML SerializationWCF supports two primary means of XML serialization. For a majority of scenarios, theDataContract attribute and its corresponding DataContractSerializer type are thepreferred means of providing this requirement. However, the secondary method, theXmlSerializerFormat attribute, provides finer control over the XML serialization process.Additionally, by providing your own implementation of IXmlSerializable, effectivelyoverriding .NET default serialization, you can control serialization entirely.We will stress that you can use the data contract capabilities most of the time when developingenterprise applications. This is especially true when you control, or at least influence,both sides of the wire. Even if you don’t have influence on both sides of the wire, you probablycan gain enough control to emit the XML as required by leveraging data contracts.In Listing 4-13, the solution (Example07) has been expanded to include a concrete Tradeclass. This class represents the object (or message) that is presented to the exchange forrequesting execution on a market order.ramrameshreddyramrameshreddy

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

Saved successfully!

Ooh no, something went wrong!