0% ont trouvé ce document utile (0 vote)
48 vues23 pages

SOAP

Transféré par

Houssem Rachdi
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
48 vues23 pages

SOAP

Transféré par

Houssem Rachdi
Copyright
© © All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF, TXT ou lisez en ligne sur Scribd

Architecture orientée services (SOA)

SOAP

I. Mouakher
3ème année LFIG
Plan

 Introduction
 Structure d’un message
 L’enveloppe SOAP
 En-tête SOAP
 Corps SOAP
 SOAP transporté par HTTP
 Traitement des messages SOAP

2
Services Web étendus
 Chercher, Publier et Consommer

3
Services Web étendus
 Pile des standards pour les Services Web étendus

4
Introduction
 SOAP est un protocole de RPC orienté objet bâti sur XML
(successeur du protocole XML-RPC).
 SOAP permet d’échanger des structures de données complexes
en XML ;
 Il permet la transmission de messages entre objets distants, ce
qui veut dire qu'il autorise un objet à invoquer des méthodes
d'objets physiquement situés sur un autre serveur.
 Le transfert se fait le plus souvent à l'aide du protocole HTTP,
mais peut également se faire par un autre protocole, comme
SMTP.
 SOAP est indépendant des langages de programmation ou des
systèmes d’exploitation sur lesquels il est implémenté

5
Concepts d’un message SOAP

 Les messages SOAP sont utilisés pour envoyer


(requête) et recevoir (réponse) des informations d’un
récepteur
 Un message SOAP peut être transmis à plusieurs
récepteurs intermédiaires avant d’être reçu par le
récepteur final (~ chaîne de responsabilité)
 Le format SOAP peut contenir des messages
spécifiques correspondant à des erreurs identifiées
par le récepteur
 Un message SOAP est véhiculé vers le récepteur en
utilisant un protocole de transport (HTTP, SMTP, …)6
Structure d’un message (1/2)

 Le protocole SOAP est composé de deux


parties :
 une enveloppe, contenant des informations sur le
message lui-même afin de permettre son
acheminement et son traitement,
 Un modèle de données, définissant le format du
message, c'est-à-dire les informations à
transmettre.

7
Structure d’un message (2/2)

8
L’enveloppe SOAP
 L’enveloppe est la racine d’un message SOAP
identifiée par la balise <soapenv:Enveloppe>
 La spécification impose que la balise et les sous
balises soient explicitement associées à un
namespace
 La spécification SOAP définit deux namespaces
 SOAP-ENV ou soapenv :
http://schemas.xmlsoap.org/soap/envelope/
 SOAP-ENC : http://schemas.xmlsoap.org/soap/encoding/
 La requête et la réponse ont la même structure

9
L’enveloppe SOAP – Exemple (requête)
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:hel="http://helloworldwebservice.lisi.ensma.fr/">
<soapenv:Header/> Message SOAP pour
<soapenv:Body> appeler l’opération
<hel:makeHelloWorld> makeHelloWorld contenant
<value>Mickael BARON</value>
</hel:makeHelloWorld> un paramètre value
</soapenv:Body>
</soapenv:Envelope>

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" Message SOAP pour
xmlns:hel="http://helloworldwebservice.lisi.ensma.fr/"> appeler l’opération
<soapenv:Header/>
simpleHelloWorld ne
<soapenv:Body>
<hel:simpleHelloWorld/> contenant pas de
</soapenv:Body> paramètre
</soapenv:Envelope>

10
L’enveloppe SOAP – Exemple (réponse)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>

<ns2:makeHelloWorldResponse xmlns:ns2="http://helloworldwebservice.lisi.ensma.fr/">
<helloWorldResult>Hello World to Mickael BARON</helloWorldResult>
</ns2:makeHelloWorldResponse>
</soapenv:Body>
</soapenv:Envelope>

Les réponses sont


sensiblement identiques
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns2:simpleHelloWorldResponse
xmlns:ns2="http://helloworldwebservice.lisi.ensma.fr/">
<helloWorldResult>Hello World to everybody</helloWorldResult>
</ns2:simpleHelloWorldResponse>
</soapenv:Body>
</soapenv:Envelope>

11
En-tête SOAP (1/2)
 L’en-tête d’un message SOAP est utilisé pour transmettre des
informations supplémentaires sur ce même message
 L’en-tête est défini par la balise <SOAP-ENV:Header>
 L’élément peut être facultatif
 Doit être placé avant le corps
 Différents usages de l’en-tête ?
 Informations authentifiant l’émetteur
 Contexte d’une transaction
 Pour certains protocole de transport (FTP par exemple), l’en-tête peut être
utilisé pour identifier l’émetteur du message
 Un message SOAP peut transiter par plusieurs intermédiaires
avant le traitement par le récepteur final
 Pattern « Chaîne de responsabilité »
 Zone lecture / écrite par les intermédiaires
12
En-tête SOAP (2/2)

13
Corps SOAP
 Le corps d’un message SOAP est constitué par un élément
<SOAP-ENV:Body>
 L’élément <SOAP-ENV:Body> peut contenir soit
 Une erreur en réponse à une requête (élément <SOAP-ENV:Fault>)
 Des informations adressées au destinataire du message SOAP respectant
un encodage déterminé
 L’encodage des informations est précisé par les bindings du
document WSDL
 Attribut style (Document et RPC)
 Attribut use (encoded et litteral)
 Pour faire simple nous utiliserons les services Web dans le
cadre de l’appel à une procédure distante

14
Corps SOAP - ENC des entrées
 Les informations adressées au destinataire de messages SOAP
doivent respectées un certain nombre de convention
 Appel d’une opération représentée par une structure
 Le nom de la structure est celui de l’opération à appeler
 Chaque paramètre de l’opération est défini comme un sous élément de la
structure
 Si un paramètre est un type complexe (Person par exemple) une nouvelle
structure est définie contenant à son tour des sous éléments…
 Le résultat est également représenté par une structure
 Le nom de la structure est celui de l’opération suivi de Response
 Les paramètres sont également structurés

15
Corps SOAP – Exemples (1/2)
 Message SOAP pour appeler l’opération addPersonWithComplexType
Paramètre de type complexe défini dans une structure (newPerson)
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:not="http://notebookwebservice.lisi.ensma.fr/">
<soapenv:Header/>
<soapenv:Body>
<not:addPersonWithComplexType>
<newPerson>
<address>Poitiers</address>
<birthyear>17081976</birthyear>
<name>BARON Mickael</name>
</newPerson>
</not:addPersonWithComplexType>
</soapenv:Body>
</soapenv:Envelope>

16
Corps SOAP - Exemples (2/2)

 Message SOAP pour appeler l’opération


addPersonWithSimpleType avec trois paramètres
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:not="http://notebookwebservice.lisi.ensma.fr/">
<soapenv:Header/>
<soapenv:Body>
<not:addPersonWithSimpleType>
<name>BARON Mickael</name>
<address>Poitiers</address>
<birthyear>17081976</birthyear>
</not:addPersonWithSimpleType>
</soapenv:Body>
</soapenv:Envelope>

17
Corps SOAP - Le retour d’erreurs
 L’élément <Fault> composé de 4 sous
élément
 <faultCode> (obligatoire) : code d’erreur
 <faultString> (obligatoire) : Explication lisible d’
un humain
 <faultActor>(optionel) : Erreur en cours de
cheminement du message (firewall, proxy..)
 <detail> Détail de l’ erreur non lié au Body du
message

18
Corps SOAP - Exemple
 Faultcode : 4 groupes(Client, Server, MustUnderstand,
VersionMismatch)

19
SOAP transporté par HTTP (1/3)
 SOAP utilise un protocole de transport pour véhiculer les messages
SOAP de l’émetteur au récepteur HTTP, SMTP, FTP, POP3 et NNTP
 Le modèle requête/réponse de SOAP convient parfaitement au modèle
requête/réponse HTTP

20
SOAP transporté par HTTP (2/3)
POST http://localhost:8080/NotebookWebService/notebook
 Requête SOAP HTTP HTTP/1.1
Content-Type: text/xml;charset=UTF-8
 Méthode de type POST SOAPAction: ""
 Nécessite un attribut User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8080
SOAPAction (URI) Content-Length: 459
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:not="http://notebookwebservice.lisi.ensma.fr/">
<soapenv:Header/>
<soapenv:Body>
<not:addPersonWithComplexType>
<newPerson>
<address>Poitiers</address>
<birthyear>17081976</birthyear>
<name>BARON Mickael</name>
</newPerson>
</not:addPersonWithComplexType>
</soapenv:Body>
</soapenv:Envelope>

21
SOAP transporté par HTTP (3/3)
 Réponse SOAP HTTP
 Exploite les codes retours HTTP Si code de type 2xx, message SOAP reçu
 Si code 500, message en erreur, le corps SOAP doit contenir fault
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Sun, 13 Dec 2009 12:00:33 GMT

<?xml version='1.0' encoding='UTF-8'?>


<soapenv:Envelope
xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns2:addPersonWithComplexTypeResponse
xmlns:ns2="http://notebookwebservice.lisi.ensma.fr/">
<addPersonWithComplexTypeResult>
true
</addPersonWithComplexTypeResult>
</ns2:addPersonWithComplexTypeResponse>
</soapenv:Body>
</soapenv:Envelope> 22
Traitement des messages SOAP

23

Vous aimerez peut-être aussi