Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
cours:app_rep_orientees_service_2016_2017:lab_contract [2019/04/24 07:36] tigli [Contracts in WCF] |
cours:app_rep_orientees_service_2016_2017:lab_contract [2019/04/24 07:57] (Version actuelle) tigli [References] |
||
---|---|---|---|
Ligne 36: | Ligne 36: | ||
== Service contract and Operation Contract == | == Service contract and Operation Contract == | ||
- | [[http://www.wcftutorial.net/Service-Contract.aspx|Follow this tutorial for more details]] | ||
- | == Data Contract == | + | Service contracts define the Interface for the service |
- | [[http://www.wcftutorial.net/Data-Contract.aspx|Follow this tutorial for more details]] | + | |
- | == Operation Contract == | + | An Operation Contract defines the method exposed to the client to exchange the information between the client and server. An Operation Contract describes what functionality is to be given to the client, such as addition, subtraction and so on. |
+ | [[http://www.wcftutorial.net/Service-Contract.aspx|Getting Started with this step by step tutorial]] | ||
+ | == Data Contract == | ||
+ | Data Contracts define the data type for variables that are the same as get and set properties but the difference is that a Data Contract in WCF is used to serialize and deserialize the complex data. It defines how data types are serialized and deserialized. Using serialization, you can convert an object into a sequence of bytes that can be transmitted over a network. Using de-serialization, you reassemble an object from a sequence of bytes that you receive from a calling application. | ||
+ | |||
+ | [[http://www.wcftutorial.net/Data-Contract.aspx|Getting Started with this step by step tutorial]] | ||
== Fault Contract == | == Fault Contract == | ||
||| | ||| | ||
- | In WCF (Windows Communication Foundation), we will not expose exception directly to client if it occurs at service level. Fault Contract is used to return error details to the other party i.e. client. | + | A Fault Contract handles the exception and understands the cause of the error that occurs in the WCF service. When we develop a managed application or service, we will handle the exception using a try- catch block, but these exceptions handlers are technology-specific. |
+ | |||
+ | [[http://www.wcftutorial.net/Fault-Contract.aspx|Getting Started with this step by step tutorial]] | ||
== Message Contract == | == Message Contract == | ||
- | DataContract has limited control over the SOAP message and all that control is related to contents inside body of the SOAP message. But there are scenarios, when we need more control over SOAP message. So, MessageContract is the answer in such cases. | + | The default SOAP message format is provided by the WCF runtime for communication between the client and the service. If it does not meet your requirements then we can create our own message format. This can be done using the Message Contract attribute. |
+ | ==== Exercices on Contracts ==== | ||
- | ==== Tutorial ==== | + | === Exercice on DataContract, Service Contract and Operation Contract === |
+ | Create a calculator service that implement add and sub operations on complex numbers instead of numerical ones. | ||
+ | This justifies to introduce DataContract for the Complex number Type. | ||
=== Exercice on Fault Contract === | === Exercice on Fault Contract === | ||
- | Create a simple calculator service with Add operation which throw general exception and send exception information from service to client with FaultException. | + | In the Add operation, throw general exception and send exception information from service to client with FaultException. |
- | [[http://www.wcftutorial.net/Fault-Contract.aspx|Follow this tutorial for more details]] | ||
- | === Exercice on Message Contract === | ||
- | [[http://www.wcftutorial.net/Message-Contract.aspx|Follow this tutorial for more details]] | ||
- | ==== References ==== | ||
- | [[https://msdn.microsoft.com/fr-fr/library/aa480190.aspx|Introduction to Building Windows Communication Foundation Services]] |