cours:app_rep_orientees_service_2016_2017:lab_contract
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
cours:app_rep_orientees_service_2016_2017:lab_contract [2018/03/28 20:08] – créée tigli | cours:app_rep_orientees_service_2016_2017:lab_contract [2019/04/24 05:57] (Version actuelle) – [References] tigli | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ===== Type of Contracts ===== | + | ==== Few reminders about WCF ABC Model ==== |
+ | |||
+ | The ABC of Windows Communication Foundation | ||
+ | |||
+ | " | ||
+ | |||
+ | * " | ||
+ | * " | ||
+ | * " | ||
+ | |||
+ | Web services zealots who read Web Service Description Language (WSDL) descriptions at the breakfast table will easily recognize these three concepts as the three levels of abstraction expressed in WSDL. So if you live in a world full of angle brackets, you can look at it this way: | ||
+ | |||
+ | * " | ||
+ | * " | ||
+ | * " | ||
+ | |||
+ | " | ||
+ | |||
+ | * You define a contract and implement it on a service | ||
+ | * You choose or define a service binding that selects a transport along with quality of service, security and other options | ||
+ | * You deploy an endpoint for the contract by binding it (using the binding definition, hence the name) to a network address. | ||
+ | |||
+ | ===== Contracts | ||
A contract is an agreement between two parties. It defines how a client should communicate with your service. In other words a contract is a platform and standard way of describing what the service does. There are the following four types of contracts in WCF ** Service Contract **: | A contract is an agreement between two parties. It defines how a client should communicate with your service. In other words a contract is a platform and standard way of describing what the service does. There are the following four types of contracts in WCF ** Service Contract **: | ||
+ | * Service contract | ||
* Data Contract | * Data Contract | ||
- | * OperationContract | + | * Operation Contract |
* Fault Contract | * Fault Contract | ||
* Message Contract | * Message Contract | ||
Ligne 11: | Ligne 34: | ||
we've already used Data Contract and Operation Contract. | we've already used Data Contract and Operation Contract. | ||
- | == Message Contract == | ||
- | DataContract has limited control over the SOAP message | + | == Service contract and Operation Contract == |
+ | |||
+ | Service contracts define the Interface for the service | ||
+ | |||
+ | An Operation Contract defines the method exposed to the client to exchange the information between | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | == Data Contract == | ||
+ | Data Contracts define the data type for variables | ||
+ | |||
+ | [[http:// | ||
== Fault Contract == | == Fault Contract == | ||
||| | ||| | ||
- | In WCF (Windows Communication Foundation), we will not expose | + | 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 |
+ | |||
+ | [[http:// | ||
+ | |||
+ | == Message Contract == | ||
+ | |||
+ | The default SOAP message format | ||
+ | |||
+ | ==== Exercices on Contracts ==== | ||
+ | |||
+ | === Exercice on DataContract, | ||
+ | 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 === | ||
+ | In the Add operation, throw general exception and send exception information from service to client | ||
- | ** Tutorial ** | ||
- | * Add to your calculator WS an exception ... for example add " | ||
- | * Test it without Fault Contract (with your Graphical Test Client extended to divide numbers). What happens ? | ||
- | * To integrate a more meaning full exception, you can add a Fault Contract following these steps : | ||
- | * Add [FaultContract(typeof(CustomFaultDetails))]in your [Service Contract] | ||
- | * and then use it in your code .. | ||
- | * // CustomFaultDetails ex = new CustomFaultDetails(); | ||
- | * // ex.ErrorID = “12345“;// | ||
- | * // ex.ErrorDetails = “Specific error details here.“; // | ||
- | * // throw new FaultException(ex, | ||
- | * Test it without Fault Contract (with your Graphical Test Client extended to divide numbers). What happens ? | ||
cours/app_rep_orientees_service_2016_2017/lab_contract.1522267721.txt.gz · Dernière modification : 2018/03/28 20:08 de tigli