11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

amrameshreddy.blog.com142 CHAPTER 4 ■ INSTALLING AND CREATING WCF SERVICESramrameshreddy.blog.comThe completed solution provides for client-side trapping of the fault exceptions leveragingthe WCF capabilities. On the client side, using WCF, apply the FaultException generic withthe ArgumentException type to trap and process as required by the fault condition, as shown inListing 4-31.Listing 4-31. Client program.cs Catch Block on Fault Exception (Partial)catch( FaultException ex ){Console.WriteLine( "ArgumentException Occurred" );Console.WriteLine( "\tAction:\t" + ex.Action );Console.WriteLine( "\tName:\t" + ex.Code.Name );Console.WriteLine( "\tMessage:\t" + ex.Detail.Message );}The FaultException type provides access to the SOAP fault headers through simple properties,allowing exception handling or reporting as needed.The service contract side of the channel is extensible by providing your own implementationof the IErrorHandler interface. This interface, when extended, is added to your ownservice contract implementations, or you can add it to the DispatchBehavior.ErrorHandlerscollection, which can provide overriding how messages are transformed into objects and dispatchedto methods.Summary of Service ContractsWe’ll now summarize some characteristics of the service contract capabilities and the typesthat are available for managing the generation of the schema and the serialization process.DataContractSerializerThis is a summary of DataContractSerializer:• Default serialization manager in WCF• Works with the DataContract, MessageContract, Serializable, and IXmlSerializabletypes• Default namespace is http://schemas.data.coontract.org/2004/07/• Defaults to fields (public or private)• Defaults to alpha sortramrameshreddyramrameshreddyXmlSerialization (XmlSerializerFormat)This is a summary of XmlSerialization:• Works with the Serializable and IXmlSerializable types• Controlled through .NET XML serialization rules—a host of XML attributes that providean explicit override of default behavior

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

Saved successfully!

Ooh no, something went wrong!