Sunteți pe pagina 1din 35

,.|s ws| ss..

|ss
Ela|are par .
Mlele|| Marwa
B| 5 Braape Z
1
!.s||smst|as
,.|s
Ws|ss..|ss
s|at|ss
|ss ,.st|as
|sss|as|ss
2
!.s||smst|as
Les donnes peuent tre prsentes uniquement sur le sereur
distant
Le sereur distant peut disposer d'une puissance de calcul ou
de capacits de stockage dont l'utilisateur local ne dispose pas ,
L'application distante peut tre utilise simultanment par un
grand nombre d'utilisateurs et sa mise a jour n'interient qu'a
un seul endroit.
Protocoles de communication lis aux SLs, applications,
3
PI accessible a un type uniquement de SL,
Complexit ,structure base de donnes, langage utilis,...,
Interaage diicile
Serices distribus
Diicult de communication et d'change de donnes entre
applications et systemes htrogenes dans des
enironnements distribus
!.s||smst|as
4
s|at|ss
|ss ss..|sss
ws|
|ss ss..|sss
ws|
|sssm||s is
s,ss|l|sst|sss
|sssm||s is
s,ss|l|sst|sss
/,,||sst|sss
i|stsstss
/,,||sst|sss
i|stsstss
Via un oimat
XMI
standaidise
3
La Web Services Interoperability
Organization
La Web Services Interoperability
Organization
une specification complte, nommee
Basic Profile
une specification complte, nommee
Basic Profile
,.s,sss
qui garantit qu`un serice serice \eb
peut tre utilis sans probleme, quel
que soit le langage de programmation
utilis
qui garantit qu`un serice serice \eb
peut tre utilis sans probleme, quel
que soit le langage de programmation
utilis
prsente un outil permettant de
riier la conormit d`un serice
\eb
prsente un outil permettant de
riier la conormit d`un serice
\eb
6
|stts tss|s|as i|sts.st|ss is s,stsmss sst ssa.sst ssa,|ss
sa sssss,t is $ (s..|ss |.|sstsi /.s||tssta.s).
|s st,|s is.s||tssta.s |/ ,.sss |s s.sst|ss is,,||sst|sss
is.s|s,,sss ss ssas|ss. s.ss ass ssas|s mst|s. m|ss s |s
i|s,ss|t|ss isat.ss s,,||sst|sss. |s ss ssss. ass s,,||sst|ss
,.|s sst ass sssi|ists tsats iss|sss ,sa. ls|.s ia |/.
,a|sa|| ss|t isll.|. as sssss s |s ssas|s mst|s..
|stts tss|s|as i|sts.st|ss is s,stsmss sst ssa.sst ssa,|ss
sa sssss,t is $ (s..|ss |.|sstsi /.s||tssta.s).
|s st,|s is.s||tssta.s |/ ,.sss |s s.sst|ss is,,||sst|sss
is.s|s,,sss ss ssas|ss. s.ss ass ssas|s mst|s. m|ss s |s
i|s,ss|t|ss isat.ss s,,||sst|sss. |s ss ssss. ass s,,||sst|ss
,.|s sst ass sssi|ists tsats iss|sss ,sa. ls|.s ia |/.
,a|sa|| ss|t isll.|. as sssss s |s ssas|s mst|s..
7
$! |m,|s ||jsst /sssss !.stsss| || ss|t ias ,.stsss|s ,s.msttsst is iss.|.s
iss s|jsts isss as ls.mst lM|. sl|s is ,sa.s|. ss|sss. sss s|jsts .|s |sts.sst.
|ss s,,||sst|sss |/! at|||ssst ssssst|s||smsst |s ,.stsss|s HII! ,sa. sllsstas. sss
ss|ssss is|jsts. ms|s s||ss ,sa.sst ss|smsst at|||ss. isat.ss ,.stsss|ss. ssmms MI!
sa 1M.
Ms|.s sss ssm is.||ss. |/! ssst ,ss as stssis.i s|m,|s iat|||sst|ss. || s is ,|as |s
islsat ist.s ,s.t|sa||s.smsst |sst. |s t.sssls.mst|ss is|jsts ss lM| stsst as mssss|sms
|st.|sssasmsst sstsa\ ss .ssssa.sss.
|ssss,ts iss ss..|sss Ws|
|ss ss..|sss Ws| ss,,a|sst sa. ass t.ssts|ss is s,ss|l|sst|sss. isst |ss
isa\ ,.|ss|,s|ss. |/! st W||.
8
$| (Ws| s..|sss |sss.|,t|ss |ssass) - ,.sssssst w|tti|s-
iss.|t is as||s mss|s.s || sst ,sss|||s iat|||ss. as ss..|ss Ws|
(,.stsss|s s at|||ss.. mst|siss ssssss|||ss. s|jsts at|||sss).
|s|tsst|ss ias issamsst W|| sst ssssst|s||s ,sa. at|||ss. as
ss..|ss Ws|. ss. ssst ss issamsst a| ss issss |s msis ism,|s|
. || ,sat st.s |a ,s. as |s|s|s| ,sa. sss.s. satsmst|asmsst as
s||sst sa ss..|ss Ws| a|| iss.|t. ls|ssst s|ss| sll|ss is s,ss|l|sst|ss
tss|s|as.
9
10
qui permet de mettre en oure et
d`appeler des serices \eb simplement
en se ondant sur les principes de
Spring, tels que l`injection de
dpendances, le modele de
programmation de Spring MVC ond
sur des annotations et le concept de
template
qui permet de mettre en oure et
d`appeler des serices \eb simplement
en se ondant sur les principes de
Spring, tels que l`injection de
dpendances, le modele de
programmation de Spring MVC ond
sur des annotations et le concept de
template
|smms ssas .sssss is |s .s|.. |ss ss..|sss Ws| ss lssisst sa. ass ma|t|tais
is ss.mss ssm,|s\ss. isst |ss isa\ ,.|ss|,s|ss ssst |/! st W||.
|at|||sst|ss is sss ss..|sss ssst isss ,ss s.|issts st sst.s|ss iss
ssst.s|stss |m,s.tsstss ss ts.mss i|sts.s,s.s||||ts st is ,s.ls.msssss.
Communaut
Spr|ng
Iramework
Spr|ng WS
ait preue d`une grande lexibilit lors de
l`exposition de serices Jaa existants en tant que
serices \eb. Il laisse notamment le choix des
briques utilises, et les supports oerts sont
simples d`utilisation.
ait preue d`une grande lexibilit lors de
l`exposition de serices Jaa existants en tant que
serices \eb. Il laisse notamment le choix des
briques utilises, et les supports oerts sont
simples d`utilisation.
11
Ms|s as|s ssst isss |ss s.sstsss is ,.|s W ,s.
.s,,s.t s sss sat.ss l.smsws.| !
Ms|s as|s ssst isss |ss s.sstsss is ,.|s W ,s.
.s,,s.t s sss sat.ss l.smsws.| !
12
|| .|sst isss s'sjsats. isss ass ||sts isjs
sssssassts i'/!|/|.smsws.| 1s.s /\|s. l||.s.
1/lW. 1|sss W. ...
|| .|sst isss s'sjsats. isss ass ||sts isjs
sssssassts i'/!|/|.smsws.| 1s.s /\|s. l||.s.
1/lW. 1|sss W. ...
|ss isa\ mss|s.ss is s.ss. as ss..|ss Ws|
ethode : Code Iirst ethode : Code Iirst
Slmple meLre
en oeuvre
Son prlnclpe
esL de creer le
servlce
Classes Classes lnLerfaces lnLerfaces
generaLlon de WSuL
correspondanL
generaLlon de WSuL
correspondanL
un ouLll un ouLll
AnnoLaLlons
!ava 3
AnnoLaLlons
!ava 3
13
&ne simple modiication d'une classe Jaa
utilise par le \ebSerice peut prooquer
la gnration d'un \SDL completement
dirent, consquence de cela, les clients
crs a partir de la prcdente ersion ne
onctionneront plus.
onc
Donc il aut gnrer a noueau leur
classe d'acces au serice web a partir
du noueau \SDL.
onc
si pour une raison ou l'autre l'PI que ous
aez choisie n'est plus maintenue, le \SDL
gnr par une autre PI ne sera pas
obligatoirement identique,
14
ethode : Contract Iirst ethode : Contract Iirst
Dans cette mthode,
l'important est le contrat du
serice, l'implmentation
tant secondaire.
deflnlr son propre WSuL
Lypes messages porLs
blndlng servlces
&ne ois le contrat cr, il suit de
crer l'implmentation a partir des
outils proposs par les PI , Script
nt, excutables, plugin dans IDL, .. ,.
13
onc
onc
Avantages
|s sssssi s.sstss sst as
ss|s ls.ss s m|sa\ isssa,s. sss
s,,||sst|ss ss ssas|ss
|s sssssi s.sstss sst as
ss|s ls.ss s m|sa\ isssa,s. sss
s,,||sst|ss ss ssas|ss
|s W|| stsst l|\s. |s
s|sssmsst i'/!| ssts ss..sa.
sst tsts|smsst t.sss,s.sst ,sa.
|ss s||ssts ia ss..|ss.
|s ss..|ss s'sst ,ss ||s s as |ssss ss
,s.t|sa||s.. || ss.s|t tsat s ls|t ,sss|||s is
.sm,|sss. ass |m,|smsstst|ss 1s.s ,s.
ass |m,|smsstst|ss ss |# ssss sllssts.
|ss s||ssts
|s ,.sm|s. s.sstss sst as
|'ss s'sst ,ss ls.tsmsst ||s s
as l.smsws.|.
|s ,.sm|s. s.sstss sst as
|'ss s'sst ,ss ls.tsmsst ||s s
as l.smsws.|.
|'as ssts ass ssas|s
8er|ce sss.s|s a|
s'sssa,s is |s ,s.t|s
mst|s.. iss
t.ssssst|sss. ,ssssis
sss ,.s,.ss s|jsts
mst|s.s
|s |'sat.s ass
ssas|s ss..|ss Ws|.
a| .s at|||ss. |s
ssas|s sss.s|s.
ms|s a| ,ssssis.s
sss ,.s,.ss |I|.
16
,.|s W is sss ssts ss ,s.mst a'ass ssa|s mst|sis |sst.sst
||.st. st is ,|as. || ss s.s as |ss ss..|sss s.|sstss |ssamsst ( ,s.
s,,ss|t|ss sa ss..|ss |!| ).
|| lsat ss.s|. as isss as ss..|ss Ws| s.|ssts |ssamsst. s'sst |s
isl|s|t|ss iss mssssss ss|ssss a| |m,s.ts |s ,|as.
|t s'sst isss sstts s,t|as as ,.|s W s sts s.ss.
|s sllst. ,.|s W s's|||s ,ss |s is.s|s,,sa. s lsa.s|. as l|s||s.
W|| ssm,|st ( msms s| |'s,t|ss .ssts ,sss|||s ). ss|a|s| stsst sssst
ssm,|s\s.
|s ssa|s |sls.mst|ss ismssiss ,s. ,.|s W sst ass isl|s|t|ss iss
mssssss ss|ssss. st ss|s ssas |s ls.ms i'as ss|sms lM|.
,.|s W is sss ssts ss ,s.mst a'ass ssa|s mst|sis |sst.sst
||.st. st is ,|as. || ss s.s as |ss ss..|sss s.|sstss |ssamsst ( ,s.
s,,ss|t|ss sa ss..|ss |!| ).
|| lsat ss.s|. as isss as ss..|ss Ws| s.|ssts |ssamsst. s'sst |s
isl|s|t|ss iss mssssss ss|ssss a| |m,s.ts |s ,|as.
|t s'sst isss sstts s,t|as as ,.|s W s sts s.ss.
|s sllst. ,.|s W s's|||s ,ss |s is.s|s,,sa. s lsa.s|. as l|s||s.
W|| ssm,|st ( msms s| |'s,t|ss .ssts ,sss|||s ). ss|a|s| stsst sssst
ssm,|s\s.
|s ssa|s |sls.mst|ss ismssiss ,s. ,.|s W sst ass isl|s|t|ss iss
mssssss ss|ssss. st ss|s ssas |s ls.ms i'as ss|sms lM|.
Spring WS
17
"assi s|s|s|. ,.|s W st ,sa.as| ! "assi s|s|s|. ,.|s W st ,sa.as| !
"aaa 7
|s ,s.t ss ssta.s. ,.|s W s'sst ,ss ia
tsat sis,ts ,sa. is,|s,s. iss ss..|sss
s\|stssts ssas ls.ms is ss..|sss
Ws|.
!s. ssst.s. |s.s is |s s.sst|ss i'as ssa.ssa
,.sjst iss |s is,s.t s.|ssts |/. ,.|s W
is.|sst t.ss |sts.ssssst.
"aaa 7
|s ,s.t ss ssta.s. ,.|s W s'sst ,ss ia
tsat sis,ts ,sa. is,|s,s. iss ss..|sss
s\|stssts ssas ls.ms is ss..|sss
Ws|.
!s. ssst.s. |s.s is |s s.sst|ss i'as ssa.ssa
,.sjst iss |s is,s.t s.|ssts |/. ,.|s W
is.|sst t.ss |sts.ssssst.
!aaraa| 7
|'as ,s|st is .as tss|s|as. ,.|s W ,ssssis is
ssm|.sa\ s.sstsss.
Isat i's|s.i. stsst |sss sa. ,.|s iss |s is,s.t. ||
|sssl|s|s is tsatss |ss lssst|ssss||tss |s|s.sstss s
ss|a|s|
|sjsst|ss is is,ssisssss. /|!. |sts.st|ss s.ss
,.|s ssa.|t, ( sss|ssssmsst /ss| ssa.|t, ) ...
!s. s\tsss|ss. ,.|s W .ssa,s.s |'s\,s.t|ss ,.|s
iss is.s|s,,sa.s.
!aaraa| 7
|'as ,s|st is .as tss|s|as. ,.|s W ,ssssis is
ssm|.sa\ s.sstsss.
Isat i's|s.i. stsst |sss sa. ,.|s iss |s is,s.t. ||
|sssl|s|s is tsatss |ss lssst|ssss||tss |s|s.sstss s
ss|a|s|
|sjsst|ss is is,ssisssss. /|!. |sts.st|ss s.ss
,.|s ssa.|t, ( sss|ssssmsst /ss| ssa.|t, ) ...
!s. s\tsss|ss. ,.|s W .ssa,s.s |'s\,s.t|ss ,.|s
iss is.s|s,,sa.s.
18
/a s|.ssa |sts.s,s.s||||ts. ,.|s W sa,,s.ts
Wssa.|t, st ,s.mst s|ss| i'at|||ss. iss ms,sss
stssis.is ,sa. |'sat|sst|l|sst|ss/sats.|sst|ss.
/a s|.ssa |sts.s,s.s||||ts. ,.|s W sa,,s.ts
Wssa.|t, st ,s.mst s|ss| i'at|||ss. iss ms,sss
stssis.is ,sa. |'sat|sst|l|sst|ss/sats.|sst|ss.
,s.mst sa is.s|s,,sa. i'ssssis. sa\ mssssss
ssas i|lls.sstss ls.mss
/!| lM| tssis.i /l. ism+j. 1|sm. t/\
||jst 1s.s ss.|s||ss .|s 1/l|. |ssts.. lM||ssss
sa ssss.s lst.ssm
,s.mst sa is.s|s,,sa. i'ssssis. sa\ mssssss
ssas i|lls.sstss ls.mss
/!| lM| tssis.i /l. ism+j. 1|sm. t/\
||jst 1s.s ss.|s||ss .|s 1/l|. |ssts.. lM||ssss
sa ssss.s lst.ssm
Spr|ng
WS
Spr|ng
WS
A cote de cela
19
M|ss ss a..s is ss..|sss ss ,.|s
in d `exposer des serices \eb a partir d`un sereur, Spring \S met en oure une chaine gnrique
et extensible d`entits de traitement de rquetes completement indpendante de la technologie de
transport des messages SOP choisie.
MessageDispatcher
!s|st isssss
s
|s,,||sst|ss
s\,sssst |ss
ss..|sss ws|
LndpointMapping
|st|ts
is|a|||ss
iss
t.s|tsmssts
Lndpointdapter
|st|ts
isis,tst|ss
ia
t.s|tsmsst
Lndpoint
|st|ts is
t.s|tsmsst
ligure: entits de traitement des requtes de Spring \S
20
|ss sst|tss a| sssst|tasst |s sa. is ,.|s Ws| s..|sss.
,ssssisst |ss ss.ssts.|st|ass sa|.sstss
Me88age|8patcler. sst|ts ssst.s|s is l.smsws.|
,s.msttsst i|m,|smssts. |s mssss|as is t.s|tsmsst
iss .sastss ss ss lssisst saa. |ss sst|tss
|si,s|stMs,,|s st |si,s|st/is,ts.. |||s |sts.s
ss|smsst iss mssss|smss s\tsss|||ss is|a|||ss st
is sst|ss iss s\ss,t|sss. |s |sts.ss. |sst|ts ss lssis
sa. as sssts\ts is msssss ss..ss,ssisst s ass
.s,.sssstst|ss iss mssssss |sis,ssissts is |s
tss|ss|s|s is t.sss,s.t
Me88age|8patcler. sst|ts ssst.s|s is l.smsws.|
,s.msttsst i|m,|smssts. |s mssss|as is t.s|tsmsst
iss .sastss ss ss lssisst saa. |ss sst|tss
|si,s|stMs,,|s st |si,s|st/is,ts.. |||s |sts.s
ss|smsst iss mssss|smss s\tsss|||ss is|a|||ss st
is sst|ss iss s\ss,t|sss. |s |sts.ss. |sst|ts ss lssis
sa. as sssts\ts is msssss ss..ss,ssisst s ass
.s,.sssstst|ss iss mssssss |sis,ssissts is |s
tss|ss|s|s is t.sss,s.t
Eapa|atMapp|ag . isl|s|t |s sst.sts|ss
is|a|||ss sl|s issssis. sa\ as|tss is
t.s|tsmsst is |s .sasts
Eapa|atMapp|ag . isl|s|t |s sst.sts|ss
is|a|||ss sl|s issssis. sa\ as|tss is
t.s|tsmsst is |s .sasts
Eapa|atapter . sst|ts isis,tst|ss iss
t.s|tsmssts s.sst |s,,s| is |ssi,s|st ,s.msttsst
is .ssi.s s\tsss|||s |s mss|s.s is,,s|s. sss
sst|tss is t.s|tsmsst
Eapa|atapter . sst|ts isis,tst|ss iss
t.s|tsmssts s.sst |s,,s| is |ssi,s|st ,s.msttsst
is .ssi.s s\tsss|||s |s mss|s.s is,,s|s. sss
sst|tss is t.s|tsmsst
Eapa|at sst|ts is t.s|tsms.sts ias s,,s| is ss..|ss ws| sll.sst |sssss
sa\ |sls.mst|sss ,.sssstss isss |s .sasts st s,sst |s .ss,ssss||||tss is
.stsa.ss. s.sstas||smsst iss |sls.mst|sss sa|ts sa\ t.s|tsmssts.|||s
,s.mst |s||tas||smsst is .ssi.s as ss..|ss ssssss|||s is mss|s.s
i|stssts ,s. ||sts.msi|s|.s iss tss|ss|s|s |/!.
Eapa|at sst|ts is t.s|tsms.sts ias s,,s| is ss..|ss ws| sll.sst |sssss
sa\ |sls.mst|sss ,.sssstss isss |s .sasts st s,sst |s .ss,ssss||||tss is
.stsa.ss. s.sstas||smsst iss |sls.mst|sss sa|ts sa\ t.s|tsmssts.|||s
,s.mst |s||tas||smsst is .ssi.s as ss..|ss ssssss|||s is mss|s.s
i|stssts ,s. ||sts.msi|s|.s iss tss|ss|s|s |/!.
21
22
W in de montrer la acilit de Spring \S, nous allons crer
un serice simple. Celui-ci a simuler une demande de
traduction de texte.
W Les messages en entre se composeront donc d'une langue
d'origine, d'une langue de destination ainsi que le texte
original. La rponse a cette demande contiendra le nom de
l'auteur de la traduction, ainsi que le texte traduit.
W in de montrer la acilit de Spring \S, nous allons crer
un serice simple. Celui-ci a simuler une demande de
traduction de texte.
W Les messages en entre se composeront donc d'une langue
d'origine, d'une langue de destination ainsi que le texte
original. La rponse a cette demande contiendra le nom de
l'auteur de la traduction, ainsi que le texte traduit.
|ss ,.st|as
23
Atbotesceoce Jo ptojet
|s,|s|smsst ia ss..|ss
Cration du projet
24
CreaLlon du conLraL
23
Iolcl le schema xSu deflnlssanL ces messages
xsschema xmlnsxshLLp//wwww3org/2001/xMLSchema
xmlnsLraducLlonhLLp//wwwhlkagebe/schema/LraducLlon
LargeLnamespacehLLp//wwwhlkagebe/schema/LraducLlon elemenLlormuefaulLquallfled
xselemenL name1raducLlon8equesL LypeLraducLlon1raducLlon8equesL1ype/
xselemenL name1raducLlon8esponse LypeLraducLlon1raducLlon8esponse1ype/
xscomplex1ype name1raducLlon8equesL1ype
xssequence
xselemenL namelangueCrlglne LypexssLrlng/
xselemenL namelangueuesLlnaLlon LypexssLrlng/
xselemenL nameLexLe LypexssLrlng/
/xssequence
/xscomplex1ype
xscomplex1ype name1raducLlon8esponse1ype
xssequence
xselemenL nameauLeur LypexssLrlng/
xselemenL nameLexLe LypexssLrlng/
/xssequence
/xscomplex1ype
/xsschema
La nomenclaLure des elemenLs esL Lres lmporLanLe le falL que ce solL
1raducLlonequest eL 1raducLlonesponse esL en effeL obllgaLolre pour permeLLre
Sprlng WS de falre la relaLlon enLre les deux au nlveau des messages SCA
Iolcl le schema xSu deflnlssanL ces messages
xsschema xmlnsxshLLp//wwww3org/2001/xMLSchema
xmlnsLraducLlonhLLp//wwwhlkagebe/schema/LraducLlon
LargeLnamespacehLLp//wwwhlkagebe/schema/LraducLlon elemenLlormuefaulLquallfled
xselemenL name1raducLlon8equesL LypeLraducLlon1raducLlon8equesL1ype/
xselemenL name1raducLlon8esponse LypeLraducLlon1raducLlon8esponse1ype/
xscomplex1ype name1raducLlon8equesL1ype
xssequence
xselemenL namelangueCrlglne LypexssLrlng/
xselemenL namelangueuesLlnaLlon LypexssLrlng/
xselemenL nameLexLe LypexssLrlng/
/xssequence
/xscomplex1ype
xscomplex1ype name1raducLlon8esponse1ype
xssequence
xselemenL nameauLeur LypexssLrlng/
xselemenL nameLexLe LypexssLrlng/
/xssequence
/xscomplex1ype
/xsschema
La nomenclaLure des elemenLs esL Lres lmporLanLe le falL que ce solL
1raducLlonequest eL 1raducLlonesponse esL en effeL obllgaLolre pour permeLLre
Sprlng WS de falre la relaLlon enLre les deux au nlveau des messages SCA
26
lmplemenLaLlon de lLndpolnL
A[ouL de dependances
Le pro[eL cree par Maven au deparL ne conLlenL que les dependances de base mals pas les Al xML
propremenL dlLes slmplemenL pour ne pas LouLes les prendre par defauL sl elles ne sonL pas uLlllsees
ll esL donc necessalre de les a[ouLer dans le CM
8eallsaLlon
d'une classe
8eallsaLlon
d'une classe
Messages en
enLrees
Messages en
enLrees
Servlce de
LraducLlon
Servlce de
LraducLlon
8eponse 8eponse
dependency
groupld[dom/groupld
arLlfacLld[dom/arLlfacLld
verslon10/verslon
/dependency
dependency
groupld[axen/groupld
arLlfacLld[axen/arLlfacLld
verslon11/verslon
/dependency
dependency
groupld[dom/groupld
arLlfacLld[dom/arLlfacLld
verslon10/verslon
/dependency
dependency
groupld[axen/groupld
arLlfacLld[axen/arLlfacLld
verslon11/verslon
/dependency
27
pub||c class 1raducLlonLndpolnL extends AbsLracL!uomayloadLndpolnL
protected LlemenL lnvokelnLernal(LlemenL requesL) throws LxcepLlon
namespace namespace namespacegeLnamespace(LraducLlon
hLLp//wwwhlkagebe/schema/LraducLlon)
// CreaLlon des requLe xaLh pour recuperer les lnformaLlons
xaLh langueCrlglneLxpresslon
xaLhnewlnsLance(//LraducLlon1raducLlon8equesL/LraducLlonlangueCrlglne)
langueCrlglneLxpresslonaddnamespace(namespace)
xaLh langueuesLlnaLlonLxpresslon
xaLhnewlnsLance(//LraducLlon1raducLlon8equesL/LraducLlonlangueuesLlnaLlon)
langueuesLlnaLlonLxpresslonaddnamespace(namespace)
xaLh LexLeLxpresslon
xaLhnewlnsLance(//LraducLlon1raducLlon8equesL/LraducLlonLexLe)
LexLeLxpresslonaddnamespace(namespace)
// 8ecuperaLlon des lnformaLlons parLlr de la requLe
SLrlng langueCrlglne langueCrlglneLxpresslonvalueCf(requesL)
SLrlng langueuesLlnaLlon langueuesLlnaLlonLxpresslonvalueCf(requesL)
SLrlng LexLeCrlglnal LexLeLxpresslonvalueCf(requesL)
// Appel au servlce pour la LraducLlon
1raducLlon LraducLlon LraducLlonServlceLradulL1exLe(langueCrlglne langueuesLlnaLlon
LexLeCrlglnal)
// CreaLlon de la reponse
LlemenL rooL new LlemenL(1raducLlon8esponse namespace)
LlemenL auLeur new LlemenL(auLeur namespace)
auLeurseL1exL(LraducLlongeLAuLeur())
LlemenL LexLe1radulL new LlemenL(LexLe namespace)
LexLe1radulLseL1exL(LraducLlongeL1exLe())
rooLaddConLenL(auLeur)
rooLaddConLenL(LexLe1radulL)
return rooL
une fols lendpolnL cree ll resLe le declarer dans le flchler de conflguraLlon de Sprlng
bean ldLraducLlonLndpolnL classbehlkagesprlngwsendpolnL1raducLlonLndpolnL
properLy nameLraducLlonServlce refLraducLlonServlce/
/bean
pub||c class 1raducLlonLndpolnL extends AbsLracL!uomayloadLndpolnL
protected LlemenL lnvokelnLernal(LlemenL requesL) throws LxcepLlon
namespace namespace namespacegeLnamespace(LraducLlon
hLLp//wwwhlkagebe/schema/LraducLlon)
// CreaLlon des requLe xaLh pour recuperer les lnformaLlons
xaLh langueCrlglneLxpresslon
xaLhnewlnsLance(//LraducLlon1raducLlon8equesL/LraducLlonlangueCrlglne)
langueCrlglneLxpresslonaddnamespace(namespace)
xaLh langueuesLlnaLlonLxpresslon
xaLhnewlnsLance(//LraducLlon1raducLlon8equesL/LraducLlonlangueuesLlnaLlon)
langueuesLlnaLlonLxpresslonaddnamespace(namespace)
xaLh LexLeLxpresslon
xaLhnewlnsLance(//LraducLlon1raducLlon8equesL/LraducLlonLexLe)
LexLeLxpresslonaddnamespace(namespace)
// 8ecuperaLlon des lnformaLlons parLlr de la requLe
SLrlng langueCrlglne langueCrlglneLxpresslonvalueCf(requesL)
SLrlng langueuesLlnaLlon langueuesLlnaLlonLxpresslonvalueCf(requesL)
SLrlng LexLeCrlglnal LexLeLxpresslonvalueCf(requesL)
// Appel au servlce pour la LraducLlon
1raducLlon LraducLlon LraducLlonServlceLradulL1exLe(langueCrlglne langueuesLlnaLlon
LexLeCrlglnal)
// CreaLlon de la reponse
LlemenL rooL new LlemenL(1raducLlon8esponse namespace)
LlemenL auLeur new LlemenL(auLeur namespace)
auLeurseL1exL(LraducLlongeLAuLeur())
LlemenL LexLe1radulL new LlemenL(LexLe namespace)
LexLe1radulLseL1exL(LraducLlongeL1exLe())
rooLaddConLenL(auLeur)
rooLaddConLenL(LexLe1radulL)
return rooL
une fols lendpolnL cree ll resLe le declarer dans le flchler de conflguraLlon de Sprlng
bean ldLraducLlonLndpolnL classbehlkagesprlngwsendpolnL1raducLlonLndpolnL
properLy nameLraducLlonServlce refLraducLlonServlce/
/bean
28
8ouLage des messages vers le LndpolnL
bean classorgsprlngframeworkwsserverendpolnLmapplngayload8ooLCnameLndpolnLMapplng
properLy namemapplngs
props
prop
keyhLLp//wwwhlkagebe/schema/LraducLlon1raducLlon8equesLLraducLlonLndpolnL/prop
/props
/properLy
properLy namelnLercepLors
llsL
bean
classorgsprlngframeworkwsserverendpolnLlnLercepLorayloadLogglnglnLercepLor
/llsL
/properLy
/bean
bean classorgsprlngframeworkwsserverendpolnLmapplngayload8ooLCnameLndpolnLMapplng
properLy namemapplngs
props
prop
keyhLLp//wwwhlkagebe/schema/LraducLlon1raducLlon8equesLLraducLlonLndpolnL/prop
/props
/properLy
properLy namelnLercepLors
llsL
bean
classorgsprlngframeworkwsserverendpolnLlnLercepLorayloadLogglnglnLercepLor
/llsL
/properLy
/bean
29
ubllcaLlon du WSuL
A ce sLade le servlce web esL foncLlonnel cesL dlre que sl les bons messages sonL envoyes la
bonne adresse lls seronL LralLes correcLemenL
bean ldLraducLlon
classorgsprlngframeworkwswsdlwsdl11uynamlcWsdl11ueflnlLlon
properLy namebullder
bean
classorgsprlngframeworkwswsdlwsdl11bullderxsd8asedSoap11Wsdl4[ueflnlLlon
8ullder
properLy nameschema value/WL8lnl/LraducLlonxsd/
properLy nameporL1ypename valueLraducLlon/
properLy namelocaLlonurl valuehLLp//localhosL9090/LraducLlonServlce//
/bean
/properLy
/bean
bean ldLraducLlon
classorgsprlngframeworkwswsdlwsdl11uynamlcWsdl11ueflnlLlon
properLy namebullder
bean
classorgsprlngframeworkwswsdlwsdl11bullderxsd8asedSoap11Wsdl4[ueflnlLlon
8ullder
properLy nameschema value/WL8lnl/LraducLlonxsd/
properLy nameporL1ypename valueLraducLlon/
properLy namelocaLlonurl valuehLLp//localhosL9090/LraducLlonServlce//
/bean
/properLy
/bean
30
CreaLlon dun cllenL
our le coLe cllenL Sprlng WS fournlL une classe uLlllLalre
WebServ|ce1emp|ate
WebServlce1emplaLe webServlce1emplaLe new WebServlce1emplaLe()
// ChargemenL dune requeLe sLockee dans un flchler
8esource resource new
ClassaLh8esource(be/hlkage/sprlng/ws/cllenL/LraducLlon8equesLxml)
// CreaLlon dun SLreamSource necessalre pour luLlllsaLlon de
WebServlce1emplaLe
SLreamSource source new SLreamSource(resourcegeLlnpuLSLream())
// CreaLlon dun SLreamuesLlnaLlon lcl redlrlge vers SysLemouL
SLream8esulL resulL new SLream8esulL(SysLemouL)
// Appel au servlce
webServlce1emplaLesendSourceAnd8ecelve1o8esulL(hLLp//localhosL90
90/LraducLlonServlce/ source
resulL)
WebServlce1emplaLe webServlce1emplaLe new WebServlce1emplaLe()
// ChargemenL dune requeLe sLockee dans un flchler
8esource resource new
ClassaLh8esource(be/hlkage/sprlng/ws/cllenL/LraducLlon8equesLxml)
// CreaLlon dun SLreamSource necessalre pour luLlllsaLlon de
WebServlce1emplaLe
SLreamSource source new SLreamSource(resourcegeLlnpuLSLream())
// CreaLlon dun SLreamuesLlnaLlon lcl redlrlge vers SysLemouL
SLream8esulL resulL new SLream8esulL(SysLemouL)
// Appel au servlce
webServlce1emplaLesendSourceAnd8ecelve1o8esulL(hLLp//localhosL90
90/LraducLlonServlce/ source
resulL)
31
AmelloraLlons du servlces
IalldaLlon
ar defauL Sprlng WS ne vallde pas les messages nl en enLree nl en sorLle CesL dlre que sl un message
1raducLlon8equesL conLlenL auLre chose que les langues dorlglne eL de desLlnaLlon eL le message Lradulre
cela sera LouL de mme envoye vers lendpolnL au rlsque deffecLuer un mauvals LralLemenL Afln de gerer cela
un lnLercepLeur esL propose 9ay|oadVa||dat|ngInterceptor Sa conflguraLlon esL compleLemenL geree dans le
conLexLe Sprlng
bean ldLraducLlonIalldaLlnglnLercepLor
classorgsprlngframeworkwssoapserverendpolnLlnLercepLorayloadIalldaLlnglnLercepLor
properLy nameschema value/WL8lnl/LraducLlonxsd/
properLy namevalldaLe8equesL valueLrue/
properLy namevalldaLe8esponse valueLrue/
/bean
bean ldLraducLlonIalldaLlnglnLercepLor
classorgsprlngframeworkwssoapserverendpolnLlnLercepLorayloadIalldaLlnglnLercepLor
properLy nameschema value/WL8lnl/LraducLlonxsd/
properLy namevalldaLe8equesL valueLrue/
properLy namevalldaLe8esponse valueLrue/
/bean
bean classorgsprlngframeworkwsserverendpolnLmapplngayload8ooLCnameLndpolnLMapplng
properLy namemapplngs
props
prop
keyhLLp//wwwhlkagebe/schema/LraducLlon1raducLlon8equesLLraducLlonLndpolnL/prop
/props
/properLy
properLy namelnLercepLors
llsL
bean
classorgsprlngframeworkwsserverendpolnLlnLercepLorayloadLogglnglnLercepLor
! A[ouL de llnLercepLeur de valldaLlon
ref beanLraducLlonIalldaLlnglnLercepLor/
/llsL
/properLy
/bean
bean classorgsprlngframeworkwsserverendpolnLmapplngayload8ooLCnameLndpolnLMapplng
properLy namemapplngs
props
prop
keyhLLp//wwwhlkagebe/schema/LraducLlon1raducLlon8equesLLraducLlonLndpolnL/prop
/props
/properLy
properLy namelnLercepLors
llsL
bean
classorgsprlngframeworkwsserverendpolnLlnLercepLorayloadLogglnglnLercepLor
! A[ouL de llnLercepLeur de valldaLlon
ref beanLraducLlonIalldaLlnglnLercepLor/
/llsL
/properLy
/bean
32
faulLcodeSCALnICllenL/faulLcode
faulLsLrlng xmllangenIalldaLlon error/faulLsLrlng
deLall
sprlngwsIalldaLlonLrror xmlnssprlngwshLLp//sprlngframeworkorg/sprlngws
cvccomplexLype24a lnvalld conLenL was found sLarLlng wlLh elemenL
LradMauvalse8allse
Cne of hLLp//wwwhlkagebe/schema/LraducLlonlangueCrlglne ls expecLed
/sprlngwsIalldaLlonLrror
/deLall
faulLcodeSCALnICllenL/faulLcode
faulLsLrlng xmllangenIalldaLlon error/faulLsLrlng
deLall
sprlngwsIalldaLlonLrror xmlnssprlngwshLLp//sprlngframeworkorg/sprlngws
cvccomplexLype24a lnvalld conLenL was found sLarLlng wlLh elemenL
LradMauvalse8allse
Cne of hLLp//wwwhlkagebe/schema/LraducLlonlangueCrlglne ls expecLed
/sprlngwsIalldaLlonLrror
/deLall
33
WSSecurlLy
une fols cela falL ll esL posslble de conflgurer un lnLercepLeur
dependency
groupldorgsprlngframeworkws/groupld
arLlfacLldsprlngwssecurlLy/arLlfacLld
verslon102/verslon
/dependency
dependency
groupldorgsprlngframeworkws/groupld
arLlfacLldsprlngwssecurlLy/arLlfacLld
verslon102/verslon
/dependency
bean ldwsSecurlLylnLercepLor
classorgsprlngframeworkwssoapsecurlLyxwssxwsSecurlLylnLercepLor
properLy namepollcyConflguraLlon valueclasspaLh/wssserverconflgxml/
properLy namecallbackPandlers
llsL
bean ldpasswordIalldaLlonPandler
classorgsprlngframeworkwssoapsecurlLyxwsscallbackSlmpleasswordIalldaLlonCallbackPand
ler
properLy nameusers
props
prop keyhlkagepassword/prop
prop keycafebabe/prop
/props
/properLy
/bean
/llsL
/properLy
/bean
bean ldwsSecurlLylnLercepLor
classorgsprlngframeworkwssoapsecurlLyxwssxwsSecurlLylnLercepLor
properLy namepollcyConflguraLlon valueclasspaLh/wssserverconflgxml/
properLy namecallbackPandlers
llsL
bean ldpasswordIalldaLlonPandler
classorgsprlngframeworkwssoapsecurlLyxwsscallbackSlmpleasswordIalldaLlonCallbackPand
ler
properLy nameusers
props
prop keyhlkagepassword/prop
prop keycafebabe/prop
/props
/properLy
/bean
/llsL
/properLy
/bean
34
|s |.smsws.| mst ss a..s ass s,,.ss|s i|.|ss ,s. |ss ssst.sts s l|s isi.ssss. sa m|sa\ |s
sss\|stssss iss ,s.si|mss \m| st s|jsts isst || s sa s|m,||l|s. |at|||sst|ss .sss s ||sjsst|ss is
is,ssissss st s as msis|s is ,.s.smmst|ss s|m||s|.s s ss|a| is s,.|s M\|.
|s|jsst|l is s,.|s ws st is .ssi.s |ss ,|as |sis,ssisstss ,sss|||ss iss tss|ss|s|ss \m|. |ss sst|tss
is.s|s,,ss. ms|s iss s,,.ss|ss ,|as ||sss s \m| ss ssst ,ss ms|ss tsajsa.s at|||ss||ss.
!a|sas |s s|s|ss is t.s|tsmsst sst ssm,|stsmsst l|s\|||s s\tsss|||s. |ss sst|tss ssst.s|ss. |ss ssi,s|sts.
,sa.sst st.s sssl|a.ss s.ss iss sssstst|sss st |sts.ss |s ms,,|s \m|/s|jst. |stts s,,.ss|s ,s.mst is
isl|s|. ,|as|sa.s mst|siss is t.s|tsmsst ,s. ssi,s|st st is t.s.s|||s. i|.sstsmsst sa. iss s|jsts iss
issssss.
/a s|.ssa is |s ,s.t|s s||ssts s,.|s ws mst ss a..s |ss msmss mssss|smss ss s s,,a,sst sa. as
tsm,|sts ,s.msttsst sstsmmsst iat|||ss. |s ms,,|s s|jst/\m|
33
|sss|as|ss

S-ar putea să vă placă și