Outils pour utilisateurs

Outils du site


Panneau latéral

Accueil

Select other language :


Apprentissage

Enseignements

Enseignements Département Informatique SI5 et Master IFI

Enseignements Département Bâtiment Polytech'Nice

Autres Formations française et étrangère

Activités administratives, Ingénierie et Innovation Pédagogiques

Apprentissage Département Informatique SI5/Master 2 ingénierie informatique EUR DS4H


Recherche

Valorisation de la Recherche

Dépôts Logiciels à l’Agence de Protection des Programme (APP)

Valorisation des résultats de recherche et transfert

Diffusion de la Culture scientifique et Technologique

Communications de presse

Séminaire ENSI Tunis

Pédagogie Innovante

Relations industrielles et socio-économique

Organisation de Manifestations

  • Conférence sur les FabLabs, Alexandre Schneider, Professeur Agrégé en Génie Mécanique, Université de Reims Champagne-Ardenne Web
  • Journées UbiMob'14 Site Web

Animation de la Recherche

U-Santé

Privé

Outils

Sources d'Informations

cours:app_rep_orientees_service_2016_2017:lab_abc

Ceci est une ancienne révision du document !


Introduction

The ABC of Windows Communication Foundation

“ABC” is the WCF mantra. “ABC” is the key to understanding how a WCF service endpoint is composed. Think Ernie, Bert, Cookie Monster or Big Bird. Remember “ABC”.

  • “A” stands for Address: Where is the service?
  • “B” stands for Binding: How do I talk to the service?
  • “C” stands for Contract: What can the service do for me?

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:

  • “A” stands for Address—as expressed in the wsdl:service section and links wsdl:binding to a concrete service endpoint address.
  • “B” stands for Binding—as expressed in the wsdl:binding section and binds a wsdl:portType contract description to a concrete transport, an envelope format and associated policies.
  • “C” stands for Contract—as expressed in the wsdl:portType, wsdl:message and wsdl:type sections and describes types, messages, message exchange patterns and operations.

“ABC” means that writing (and configuring) a WCF service is always a three-step process:

  • 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.

Creation of various endpoints in configuration

Endpoints provide clients with access to the functionality a Windows Communication Foundation (WCF) service offers. You can define one or more endpoints for a service by using a combination of relative and absolute endpoint addresses, or if you do not define any service endpoints, the runtime provides some by default for you. This topic shows how to add endpoints using a configuration file that contain both relative and absolute addresses.

question 1 : Adresses
  • Take the calculator Web service (with and add and sub between two value)
  • Add various endpoints for this same Web service only changing the web adress (A) on the localhost (only changing port and path so).
  • To test them write a graphical client that propose add and sub operations (two Buttons) between two values (two (TextBox)and that displays the result (Label), on two or three different adresses at least.

Comments : When configuring a service in Visual Studio, use either a Web.config file or an App.config file to specify the settings. The choice of the configuration file name is determined by the hosting environment you choose for the service. If you are using IIS to host your service, use a Web.config file. If you are using any other hosting environment, use an App.config file

Use the Configuration Editor Tool in Visual Studio(or SvcConfigEditor.exe)

question 2 : Bindings
  • Take the calculator Web service (with and add and sub between two value)
  • Define two endpoints : one with basicHttpBinding and the other with wsHttpBinding
  • What are the differences between both services now ?
  • To test them write a graphical client that propose add and sub operations (two Buttons) between two values (two (TextBox)and that displays the result (Label), on the two endpoints.
question 3 : Contracts

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.

  • Add to your calculator WS an exception … for example add “divide” operation and threw an exception on division by zero: throw new Exception(“Exception occurred at service level : Divide by zero”);
  • 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,“Reason: Testing…..“);
  • Test it without Fault Contract (with your Graphical Test Client extended to divide numbers). What happens ?

References

[[Lien externeIntroduction to Building Windows Communication Foundation Services]]

cours/app_rep_orientees_service_2016_2017/lab_abc.1522266488.txt.gz · Dernière modification: 2018/03/28 21:48 par tigli