Vous êtes sur la page 1sur 39

End-2-end-105-PO-Processing

2 Creating the Credit Card


Validation Service
2 Creating the Credit Card Validation Service ............................................................................ 1
2.1 Introduction ........................................................................................................................... 1
2.2 Designing the flow ............................................................................................................... 2
2.3 Creating a new application ................................................................................................. 2
2.4 Adding the database adapter .............................................................................................
2.! Adding the "ediator Co#ponent ................................................................................... 2$
2. Adding a transfor#ation to the "ediator co#ponent .................................................. 32
2.% Deplo&ing the application ................................................................................................ 3
2.' (esting the application ....................................................................................................... 3
2.) *perations and na#ing ...................................................................................................... 3'
2.1 Introduction
Note: (he solution for this chapter can be found in c:\po\solutions\ch2.
(o run this solution+ &ou #ust first co#plete Chapter 1 to set up the
application.
In this section &ou will build a si#ple credit service. (his service will
loo, up the status -valid or not valid. of a given credit card fro# a
database. /ou will learn0
(he basic steps involved in building a S*A co#posite
pro1ect
2ow to e3pose S45 operations over S*A6 7uic,l& and
easil&
(he i#ple#entation of this service uses a "ediator to route the re7uest
to the database adapter which e3ecutes the 7uer& on the database and
returns a result. *nce done+ our "ediator flow will loo, li,e 8igure 1.
Figure 1 Credit Service
Section 2.6 Creating the Credit Card Validation Service 2-1
End-2-end-105-PO-Processing
2.2 Designing the flow
/ou will create a new co#posite application that will be invo,ed as a
service fro# &our #ain application to be designed later. (his co#posite
7ueries the database for the credit card nu#ber and returns its status.
2.3 Creating a new application
1. Start 9Developer.
2. Create a new application. (here are various wa&s and shortcuts to do
this+ and in this case choose File > New fro# the #enu.
3. Select All Technologies in the top tab if present -onl& if &ou have
a pro1ect open.
4. 8ro# the Categories tree+ clic, on General -not e3pand it..
. Select Generic Application fro# the Items field.
2-2 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 2 Creating a new application
6. Clic, OK.
!. In the subse7uent Create Generic Application dialog set the
following fields+ leaving the others with their default values0
Application Name: CreditCardValidation
Directory: C0:po:CreditCardValidation
Section 2.6 Creating the Credit Card Validation Service 2-3
End-2-end-105-PO-Processing
Figure 3 Create application dialog
". Clic, Next.
#. ;hen &ou create a new application &ou are pro#pted to create a
new pro1ect. Set the following fields0
ro!ect Name: validation8orCC
Directory:
C0:po:CreditCardValidation:validation8orCC
ro!ect Technologies: S*A
Figure 4 New project dialog
2-4 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
1$. Clic, Next.
11. (he ne3t step allows &ou to choose to start with an e#pt& co#posite+
or with a co#ponent alread& added. In this case+ select "mpty
Composite#
12. Clic, Finish#
Figure 5 New SOA Composite dialog
13. /ou will now have an e#pt& canvas displa&ing three swi# lanes0
services+ co#ponents+ and references.
Figure 6 New composite diagram
Section 2.6 Creating the Credit Card Validation Service 2-
End-2-end-105-PO-Processing
2.4 %dding the data&ase adapter
1. /ou can now start building the application. Drag<and<drop a
database adapter onto the $e%erences swi# lane+ as shown in 8igure
%. If &ou don=t have the Co#ponent 6alette open+ fro# the #enu
select &iew > Component alette. If the Co#ponent 6alette is not
showing the S*A co#ponents+ select 'OA fro# the drop down list.
Figure !ragging a data"ase adapter onto t#e composite
2. (his database adapter call will return a result of valid or invalid
for a given credit card fro# the database. A wi>ard ta,es &ou
through the steps of configuring the database adapter.
(he title bar of the wi>ard dialog shows the step nu#ber. Clic, Next
on step 1.
3. ?nter the following details on step 20
'er(ice Name: getCreditValidation
2-6 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure $ !ata"ase adapter% step 2
4. Clic, Next to go to step 3.
Figure & Creating a new data"ase connection
. (he database adapter will connect to the database+ and in order
to do that it needs a database connection which contains all the
details needed to connect to the database. /ou can pre<create a
database connection or create one on the fl&. Since a database
connection hasn=t been created &et+ &ou will create one fro# here.
Section 2.6 Creating the Credit Card Validation Service 2-!
End-2-end-105-PO-Processing
Clic, the green plus icon to the right of the Connection poplist to
create a new database connection.
6. In the Create Data)ase Connection dialog+ enter the following
details0
Connection Name: soade#oDatabase
Connection Type: *racle -9D@C.
*sername: soade#o
asswor+: soade#o
'a(e asswor+: Chec,ed
"nter C,stom -D.C *$/: Anchec,ed
Dri(er: thin
0ost Name: localhost
-D.C ort: 1!21 -or the port nu#ber of &our database.
'ID: B? -or the SID of &our database.
Figure 1' Create !ata"ase Connection dialog
2-" Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
!. Clic, the Test Connection button and verif& that &our connection
wor,s.
". Clic, OK to return to step 3 of the Data)ase A+apter
Con%ig,ration wi>ard.
Figure 11 Adapter Con(iguration wi)ard% Step 3% a(ter creating new connection
#. "a,e sure &our Connection specifies the correct connection. In
addition+ the 9CDI Ca#e #ust #atch the data source connection
pool 9CDI Ca#e &ou entered in Chapter 1.
1$. Clic, Next.
Section 2.6 Creating the Credit Card Validation Service 2-#
End-2-end-105-PO-Processing
11. Set the following fields0
er%orm an Operation on a Ta)le: Selected
'elect: Chec,ed
All other fields should be unchec,ed+ see 8igure 12.
Figure 12 Adapter Con(iguration wi)ard% Step 4
12. Clic, Next.
13. In step !+ clic, the Import Ta)les button to bring up the Import
Ta)les dialog.
14. Clic, the 1,ery button to retrieve the list of tables for the
soademo user fro# the database. If &ou do not see an& tables+ go bac,
to Chapter 1 where &ou created the table and review the instructions
to #a,e sure it was created properl& for the soademo user.
1. Select the C$"DITCA$DINFO table and #ove it to the 'electe+
field b& pressing the A++ shuttle button.
2-1$ Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 13 Adapter Con(iguration wi)ard% importing ta"les
16. Clic, OK.
1!. @ac, in step ! of the Data)ase A+apter Con%ig,ration wi>ard+
clic, the C$"DITCA$DINFO table to select it.
Section 2.6 Creating the Credit Card Validation Service 2-11
End-2-end-105-PO-Processing
Figure 14 !ata"ase Adapter Con(iguration wi)ard% step 5
1". Clic, Next.
1#. Step of the wi>ard lets &ou override or define the pri#ar& ,e&
for &our table. In this case no pri#ar& ,e& is defined in the database+
so &ou=ll need to specif& it. Chec, CCN*2."$ and leave the rest
unchec,ed.
2-12 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 15 !e(ining t#e primar* +e*
2$. Clic, Next.
21. Step % lets &ou define relationships if &ou are selecting fro#
#ultiple tables. Since there is onl& a single table there is no
relationship to define.
Clic, Next.
22. Anchec, all fields+ in step '+ e3cept stat,s. (hat is the onl&
colu#n we want to 7uer& fro# the database.
Section 2.6 Creating the Credit Card Validation Service 2-13
End-2-end-105-PO-Processing
Figure 16 !ata"ase Adapter Con(iguration wi)ard% step $
23. Clic, Next.
24. Step ) is where &ou can specif& &our selection criteria. In this case
&ou will add a para#eter to the 7uer&. (he para#eter will be set at
runti#e to select the row for the credit card &ou want.
Clic, the Add button to add a new para#eter called ccn). Clic,
OK.
2-14 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 1 !ata"ase Adapter Con(iguration wi)ard% adding a parameter
2. @ac, in step )+ clic, the "+it button to bring up the "xpression
.,il+er dialog.
26. 6ress the A++ button to add a new condition
Section 2.6 Creating the Credit Card Validation Service 2-1
End-2-end-105-PO-Processing
Figure 1$ Adding a new condition
2!. 6ress the "+it button in the First Arg,ment section.
2". In the 1,ery Key dialog select ccn,m)er.
2-16 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 1& Selecting t#e column (or t#e condition
2#. Clic, OK.
3$. In the 'econ+ Arg,ment section+ select arameter.
31. ?nsure ccn) is selected in the poplist.
Section 2.6 Creating the Credit Card Validation Service 2-1!
End-2-end-105-PO-Processing
Figure 2' Speci(*ing t#e parameter
32. Clic, OK.
33. @ac, in step ) &ou see the su##ar& of the 7uer& that &ou
specified+ as shown in. 8igure 21. (he para#eter ccn) will be
populated at runti#e and the 7uer& will select a row based on that
para#eter
2-1" Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 21 Summar* o( selection criteria
34. Clic, Finish.
(he database adapter will process &our choices and
generate a service that i#ple#ents the operation &ou specified+
which #eans &our pro1ect will now contain a new ;SD5 file to
represent that service0 getCreditValidation.wsdl. (he
co#posite diagra# has been updated with this service as shown in
8igure 22.
Section 2.6 Creating the Credit Card Validation Service 2-1#
End-2-end-105-PO-Processing
Figure 22 Composite updated wit# data"ase adapter service
2. %dding the 'ediator Co(ponent
(he "ediator is the co#ponent in charge of routing in the S*A Suite.
/ou will add a "ediator co#ponent to route a re7uest to the service &ou
1ust created with the database adapter.
1. Drag a "ediator co#ponent onto the co#posite diagra# in the
Components swi# lane.
Figure 23 Adding a ,ediator component
2-2$ Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
2. In the Create 2e+iator dialog+ specif& these settings0
Name: DouteDe7uest
Template: Define Interface 5ater
A t&pical co#posite application will have #an& co#ponents+ but
onl& so#e of the# will have a publicall& e3posed web services
interface. (he co#posite editor in 9Developer gives &ou the fle3ibilit&
to define the interface now+ choose an e3isting interface+ or to define
the interface later.
Figure 24 New ,ediator component settings
3. Clic, OK.
4. /ou will create a ;eb Service interface to e3pose this service using
S*A6 bindings. Drag a ;eb Service adapter to the "xpose+ 'er(ices
swi# lane.
Section 2.6 Creating the Credit Card Validation Service 2-21
End-2-end-105-PO-Processing
Figure 25 Adding a -e" Services inter(ace
. In the Create 3e) 'er(ice dialog that appears+ set the following
fields0
Name: getStatus@&CC
Type: Service
6. Clic, the cog icon ne3t to the 3'D/ File field to define the interface.
Figure 26 Creating a new service inter(ace
!. (he Create 3'D/ dialog lets &ou specif& the #essage invocation
t&pes for the service. /ou have been given an e3isting B"5 sche#a
definition -BSD. that specifies the t&pes of the input and output for
the service which &ou will reuse for this application.
2-22 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Clic, the flashlight icon to the right of the *$/ field to browse for a
sche#a file.
Figure 2 !e(ining t#e message invocation t*pes
". In the Type Chooser dialog+ clic, the Import 'chema File button.
Figure 2$ .mporting a sc#ema (ile
#. In the Import 'chema File dialog+ clic, the flashlight to browse for
the sche#a file.
Section 2.6 Creating the Credit Card Validation Service 2-23
End-2-end-105-PO-Processing
Figure 2& .mporting a sc#ema (ile
1$. In the 'CA $eso,rce /oo4,p+ #a,e sure File 'ystem is selected.
11. Cavigate to and select c:\po\schemas\creditcheck.xsd.
Figure 3' Selecting t#e sc#ema (ile
12. Clic, O4.
13. @ac, in the Import 'chema File dialog+ #a,e sure Copy to ro!ect is
selected.
2-24 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 31 .mport Sc#ema File dialog
14. Clic, OK.
1. /ou #a& get a Copy File dialog as,ing if &ou want to cop& the file to
&our pro1ect. If so+ sa& 5es.
Figure 32 Cop* (ile con(irmation
16. @ac, in the Type Chooser dialog+ e3pand the ro!ect 'chema Files E
cre+itchec4#xs+ nodes.
1!. Select cre+itcar+'tat,s$e6,est.
Section 2.6 Creating the Credit Card Validation Service 2-2
End-2-end-105-PO-Processing
Figure 33 Selecting t#e sc#ema t*pe
1". Clic, OK.
1#. (he Create 3'D/ dialog should now loo, li,e 8igure 34. Do not
select OK &etF
Figure 34 Setting t#e /e0uest invocation t*pe
2-26 Creating the Credit Card Validation Service Section 2.!

End-2-end-105-PO-Processing
2$. In a si#ilar wa&+ set the #essage t&pes for the repl& and fault to
cre+itcar+'tat,s and error. (he onl& difference is that &ou donGt
need to i#port the sche#a definition again because itGs now part of
&our pro1ect.
Clic, the $eply tab.
21. Clic, the flashlight icon to the right of the *$/ field.
22. ?3pand the ro!ect 'chema Files > cre+itchec4#xs+ nodes.
23. Select cre+itcar+'tat,s.
Figure 35 C#oosing t#e repl* sc#ema t*pe
24. Clic, OK.
2. (he repl& #essage t&pe should loo, li,e 8igure 3.
Section 2.6 Creating the Credit Card Validation Service 2-2!
End-2-end-105-PO-Processing
Figure 36 1#e repl* invocation t*pe
26. Clic, the Fa,lt tab.
2!. Asing the sa#e #ethod+ select the error t&pe. (he Fa,lt tab should
loo, li,e 8igure 3%.
2-2" Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 3 1#e (ault invocation t*pe
2". Clic, OK to close the Create 3'D/ dialog.
2#. (he Create 3e) 'er(ice dialog should now loo, li,e 8igure 3'.
@e careful here << If &ou clic, the cog icon again &ou will have to set
all three invocation t&pes again -re7uest+ repl&+ and fault..
Section 2.6 Creating the Credit Card Validation Service 2-2#
End-2-end-105-PO-Processing
Figure 3$ 1#e we" service inter(ace
3$. Clic, OK.
31. Cow the co#ponents can be connected << or HwiredH << together. ;ire
the inbound web service binding to the "ediator co#ponent0
Figure 3& -iring t#e we" service inter(ace to t#e ,ediator component
2-3$ Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
32. ;ire the "ediator co#ponent to the database adapter service0
Figure 4' -iring t#e ,ediator component to t#e data"ase adapter service
33. /ou #a& be pro#pted to choose the operations -onl& if &ou selected
#ore than one database operations when &ou set up the database
adapter service.. If so+ use these settings0
2e+iator Operation: e3ecute
Target Operation: getCreditValidationSelect
Figure 41 C#oosing t#e operations
Section 2.6 Creating the Credit Card Validation Service 2-31
End-2-end-105-PO-Processing
34. Clic, OK.
3. (he co#posite diagra# now loo,s li,e 8igure 42 and gives an
overview of &our application.
Figure 42 1#e composite view
2.6 %dding a transfor(ation to the 'ediator
co(ponent
In this section &ou will #odif& the $o,te$e6,est "ediator co#ponent
to do an BS5( transfor#ation on the #essage pa&load. (hatGs because
the inco#ing #essage to our publicl& e3posed service -get'tat,s.yCC.
is in a different for#at than the service created b& the database adapter
-getCre+it&ali+ation..
Cot onl& does the "ediator route re7uests between endpoints -which
&ou did b& wiring the# together. but it can also transfor# the data as it
passes through.
1. *ne wa& to drill down into a specific co#ponent is to double<clic, it
fro# the co#posite diagra#. Double<clic, the $o,te$e6,est
"ediator co#ponent to open the "ediator editor.
2-32 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 43 1#e ,ediator editor
2. Clic, the transfor#ation icon to the right of the Trans%orm *sing
field in the re7uest section -thatGs the first Trans%orm *sing field..
Figure 44 Adding a trans(ormation (or t#e re0uest
3. Select Create New 2apper File and accept the default na#e.
Section 2.6 Creating the Credit Card Validation Service 2-33
End-2-end-105-PO-Processing
Figure 45 Creating a new mapper (ile
4. Clic, OK to open the #apping editor.
. ?3pand all the nodes on both sides. /ou can do it #anuall&+ or right<
clic, 7so,rces> and select "xpan+ All. Do the sa#e for 7target> on
the right<hand side.
6. "ap CCN,m)er fro# the source side to ccn) on the target side b&
dragging and dropping it. 8igure 4 shows dragging the ele#ent
across+ and 8igure 4% shows what it loo,s li,e when itGs #apped.
Figure 46 !ragging an dropping an element to map it
Figure 4 1#e completed mapping
!. Save and close the #apper. /ou #a& need to use the tab bar scroll
buttons to navigate right to get to the close window icon.
Alternativel& &ou can press Ctrl<S to save the #apping+ then Ctrl<;
to close it.
". @ac, in the "ediator editor+ clic, the transfor#ation icon to the right
of the Trans%orm *sing field in the repl& section -thatGs the second
Trans%orm *sing field..
2-34 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Figure 4$ Adding a trans(ormation (or t#e re0uest
#. In the $eply Trans%ormation 2ap dialog select Create New 2apper
File and accept the default na#e.
1$. Clic, OK to open the #apper.
11. ?3pand all the source and target nodes.
12. "ap stat,s fro# the source to cre+itcar+stat,s fro# the target.
Figure 4& ,apping t#e repl* t*pes
13. Save and close the #apper to return to the "ediator editor.
Figure 5' 1#e ,ediator service wit# mappings de(ined
14. Save and close the "ediator editor to return to the co#posite
diagra#. /ou can use the toolbar buttons or the #enu+ or si#pl&
press Ctrl<S to save and Ctrl<; to close this tab.
Section 2.6 Creating the Credit Card Validation Service 2-3
End-2-end-105-PO-Processing
2.! Deplo)ing the application
(he first design iteration is co#plete and &ou are now read& to deplo&
the co#posite. (he steps to run and test a co#posite application are
e3plained in Appen+ix A Deploying an+ $,nning a Composite
Application Dead that docu#ent now if this is the first ti#e &ou are
running and testing a co#posite application. Appen+ix A follows
Chapter 8 in the tutorial.
2." *esting the application
If &ou are not sure how to deplo&+ read the steps in Appen+ix A
Deploying an+ $,nning a Composite Application.
1. After &ou have deplo&ed &our co#posite+ open ?nterprise "anager
at the following lin,0 http0IIlocalhost0%$$1Ie#
2. Clic, the (ali+ationForCC lin, in the 'OA section.
3. *pen the (est page b& clic,ing the Test button
2-36 Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
4. In the CCN,m)er field+ enter a credit nu#ber. In this case+ enter
9:;<=9:;<=9:;<=9:;< in the CCN,m)er field which is a valid credit
card and returns the status+ JVA5ID.=
. Clic, the Test 3e) 'er(ice button.
6. /ou will get a response fro# the service which will indicate if the
credit card is valid or not. 2ere is the output for a valid credit card0
!. Select the $e6,est tab+ and this ti#e enter <;:9=<;:9=<;:9=<;:9 in the
CCN,m)er field which is an invalid credit card.
". Clic, the Test 3e) 'er(ice button to see the output.
#. In an upco#ing chapter+ &ou will create a new application that calls
this service+ so &ouGll need to ,now the ;SD5 location for it.
Section 2.6 Creating the Credit Card Validation Service 2-3!
End-2-end-105-PO-Processing
Appen+ix A Deploying an+ $,nning a Composite Application
contains instructions on how to get the ;SD5 location in the section
titled Getting the ser(ice +escription >3'D/?.
In this case it will loo, so#ething li,e0
http0IIlocalhost0'$$1Isoa<infraIservicesICreditCardValidationI
validation8orCCIgetStatus@&CCK;SD5
2.# +perations and na(ing
(his section gives &ou all of the operations and na#es for ob1ects created
in this chapter. ?3perienced users can use this for creating the ob1ects in
this chapter 7uic,l&. An& 7uestions on details for a particular operation
listed here can be found in the preceding sections. (he infor#ation is
divided b& the sections in this docu#ent.
Section 2.3 Creating a new application
Application Name: CreditCardValidation
Directory: C0:po:CreditCardValidation
ro!ect Name: validation8orCC
Directory:
C0:po:CreditCardValidation:validation8orCC
ro!ect Technologies: S*A
"mpty Composite
Section 2.4 Adding the database adapter
D)A+apter 'er(ice Name: getCreditValidation
Create Data)ase Connection details0
- Connection Name0 soade#oDatabase
- Connection Type0 *racle -9D@C.
- *sername0 soade#o
- asswor+0 soade#o
- 'a(e asswor+0 Chec,ed
- "nter C,stom -D.C *$/0 Anchec,ed
- Dri(er0 thin
- 0ost Name0 localhost
- -D.C ort0 1!21 -or the port nu#ber of &our database.
- 'ID0 B? -or the SID of &our database.
- -n+i name0 eisID@Isoade#oDatabase
2-3" Creating the Credit Card Validation Service Section 2.!
End-2-end-105-PO-Processing
Operation0 Select
Import CD?DI(CADDIC8* table
rimary 4ey CCCA"@?D
Attri),te Filtering0 status
A++ a new parameter0 ccnb
A++ 3here cla,se0 ccnu#ber L Mccnb
Section 2.! Adding the "ediator Co#ponent
Create 2e+iator: DouteDe7uest
Template: Define Interface 5ater
Create 3e) 'er(ice: getStatus@&CC
Type: Service
3'D/ )ase+ on: c0:po:sche#as:creditchec,.3sd
$e6,est: creditcardStatusDe7uest
$eply: creditcardStatus
Fa,lt: error
3ire: service to #ediator to adapter
Section 2. Adding a transfor#ation to the "ediator co#ponent
2e+iator trans%orm: "ap CCCu#ber fro# the source side to
ccnb
2e+iator trans%orm %or reply: "ap status fro# the source to
creditcardstatus fro# the target.
(he application is co#pleted. Continue with Section 2.% above to deplo&
and test &our application.
Section 2.6 Creating the Credit Card Validation Service 2-3#

Vous aimerez peut-être aussi