soa lab manuals

Upload: aishutherocxtar

Post on 07-Aug-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/20/2019 Soa Lab Manuals

    1/28

     

    DEPARTMENT OF INFORMATION

    TECHNOLOGY

    IT2406

    SERVICE ORIENTED ARCHITECTURE LAB

    LAB MANUAL

  • 8/20/2019 Soa Lab Manuals

    2/28

    CREATION OF ADDITION WEB SERVICE:

    Aim:

    To create a web service for adding few numbers using NetBeans.

    Alg!i"#m:

    1. Using the Netbeans API create a project of the type web appication.!. "reate a web service in the project.

    #. "ic$ on the %esign tab and design the prototype of the web service.

    &. "ic$ on source tab and modify the appication ogic of the web service.

    '. (ave the project.). *ight cic$ on the project and cic$ on depoy and undepoy.

    +. Then test the web service.

    STEPS TO CREATE ADDITION WEB SERVICE:

    I.(T,P( -* "*,ATIN/ (,*0,* (I%, P*,"T21.P,N -ie34New34NewProject345eb345eb App..cic$ ne6t

    !./ive Project name34addserver7then cic$ finish

  • 8/20/2019 Soa Lab Manuals

    3/28

    #.The addserver project wi be created in right side.*ight cic$ it and choose the

    foowing./ive the web service name as addweb.

    &.After this in eft side 8the design window choose the add operation

  • 8/20/2019 Soa Lab Manuals

    4/28

    '. /ive the foowing in the opened window for creating operation

     Name34add

    ).Then in the source add the foowing code and save it.

     pac$age org9

    import java6.jws.5eb:ethod9

    import java6.jws.5ebParam9import java6.jws.5eb(ervice9

    ;5eb(ervice  ?@@

      @ 5eb service operation  @?  ;5eb:ethod

  • 8/20/2019 Soa Lab Manuals

    5/28

      D

    D

    +.Then right cic$ on add addserver and perform undepoy and depoy7after that right

    cic$ on addweb and do test web service to see the (AP reEuest and response message.

    /ive some integers and cic$ add.

  • 8/20/2019 Soa Lab Manuals

    6/28

    CREATION OF WEB SERVICE CLIENT

    Aim:

    To create a web service for adding few numbers using NetBeans and write cient side

    code to invo$e the web service.

    Alg!i"#m:

    1. Using the Netbeans API create a project of the type web appication.

    !. "reate a web service in the project.

    #. "ic$ on the %esign tab and design the prototype of the web service.

    &. "ic$ on source tab and modify the appication ogic of the web service.'. (ave the project.

    ). *ight cic$ on the project and cic$ on depoy and undepoy.

    +. Then test the web service.

    F. "reate another web appication project and create a jsp fie.G. *ight cic$ on project and cic$ on create web service cient.

    1H. Browse and choose the web service created i.e wsd ur11. %rag and drop the web service reference to the source code window.

    1!. Then pass the appropriate parameters to the web service cient and invo$e the web

    service.

    STEPS TO CREATE CLIENT SIDE PRO$ECT:

    1.create the new project as above and give the name as addcient.

    !. addcient project wi be created. right cic$ it and choose the foowing.

  • 8/20/2019 Soa Lab Manuals

    7/28

    #.Then browse and choose the addweb wsd fie

    &.Then choose the foowing and add the source code in inde6.jsp and save it.

  • 8/20/2019 Soa Lab Manuals

    8/28

    Inde6.jsp source code

    J;page contentTypete6t?htm page,ncodingUT-3FJ4K%"TLP, MT: PUBI" 3??5#"??%T% MT: &.H1 Transitiona??,N

      http2??www.w#.org?T*?htm&?oose.dtd4htm4  head4

      meta http3eEuiv"ontent3Type contentte6t?htm9 charsetUT-3F4

      tite4(P Page?tite4

      ?head4  body4

      h14Meo 5ordK?h14

      form name actionactionn.jsp methodpost4 ,nter 1st No2input namefst typete6t ?4br?4

    ,nter !nd No2input namesnd typete6t ?4br?4

     input nameo$ typesubmit vaueAdd ?4?form4

      ?body4

    ?htm4

    '.Then create an action.jsp as foows.

    *ight cic$ web page in addcient and choose new34jsp

     Name2action

  • 8/20/2019 Soa Lab Manuals

    9/28

    "ic$ finish

    ).cic$ on the actionn.jsp page..then right cic$ in it and choose web service cient

    reference 34ca web service

    +.The invo$e the add service.

  • 8/20/2019 Soa Lab Manuals

    10/28

    F. add the foowing code in the action.jsp

    J;page contentTypete6t?htm page,ncodingUT-3FJ4

    K%"TLP, MT: PUBI" 3??5#"??%T% MT: &.H1 Transitiona??,N  http2??www.w#.org?T*?htm&?oose.dtd4

    htm4

      head4  meta http3eEuiv"ontent3Type contentte6t?htm9 charsetUT-3F4

      tite4(P Page?tite4

      ?head4  body4

      h14Meo 5ordK?h14

      J

     (tring a1reEuest.getParameter

  • 8/20/2019 Soa Lab Manuals

    11/28

      J33 end web service invocation 33J4hr?4

      ?body4

    ?htm4F.finay undepoy and depoy the addcient and run it.

  • 8/20/2019 Soa Lab Manuals

    12/28

    CREATION OF A WEB SERVICE WITH DATABASE CONNECTIVITY

    Aim:

    To create a web service for adding few numbers using NetBeans and write cient sidecode to invo$e the web service.

    Alg!i"#m:

    1. Using the Netbeans API create a project of the type web appication.

    !. ,stabish connectivity with the database aong with the necessary authentication

     parameters.#. "reate a web service in the project.

    &. "ic$ on the %esign tab and design the prototype of the web service.

    '. "ic$ on source tab and modify the appication ogic of the web service.

    ). (ave the project.+. *ight cic$ on the project and cic$ on depoy and undepoy.

    F. Then test the web service.G. "reate another web appication project and create a jsp fie.

    1H. *ight cic$ on project and cic$ on create web service cient.

    11. Browse and choose the web service created i.e wsd ur1!. %rag and drop the web service reference to the source code window.

    1#. Then pass the appropriate parameters to the web service cient and invo$e the web

    service.

    STEPS FOR CREATING TRAVEL WEB SERVICE

    R%&'i!%m%("):

    *+M,)&l

    *+(%"-%.() /i"# gl.)) i)#12 )%!1%!

    IB%!% 3!%."i(g !5%3" i( (%" -%.() "#% ll/i(g:

    1.insta :ysE setup fie and the gui toos .!.Then open the mysE browser in the start34programs34mysE34mysE browser 

  • 8/20/2019 Soa Lab Manuals

    13/28

    Then restore the bac$ up

  • 8/20/2019 Soa Lab Manuals

    14/28

    1.create the server project as before and with the foowing changes.

    Project name2 PNBusTraves

    !.web service name2PNBusTravesPac$age name2$pnpac$ 

    #.in design window

    peration name2getBusParameters2

    (ource and destination with the type as (tring.

    &.Add the foowing code in source pac$age $pnpac$9

    import java.sE."onnection9

    import java.sE.%river:anager9

    import java.sE.*esut(et9import java.sE.(tatement9

    import java.uti.Arrayist9

    import java.uti.Mashtabe9

    import java6.jws.5eb:ethod9import java6.jws.5ebParam9

    import java6.jws.5eb(ervice9?@@

     @

     @ ;author user  @?

    ;5eb(ervice

      ?@@  @ 5eb service operation

      @?

      ;5eb:ethod

  • 8/20/2019 Soa Lab Manuals

    15/28

      (tatement stcon.create(tatement

  • 8/20/2019 Soa Lab Manuals

    16/28

    "I,NT (I%,2

    1.create new project

     Name2cient1

    !.As before in addition program create web service reference.

    #.The source code for inde6.jsp and action8jsp are as foow.Inde6.jsp2

    J;page contentTypete6t?htm page,ncodingUT-3FJ4

    K%"TLP, MT: PUBI" 3??5#"??%T% MT: &.H1 Transitiona??,N

      http2??www.w#.org?T*?htm&?oose.dtd4

    htm4

      head4  meta http3eEuiv"ontent3Type contentte6t?htm9 charsetUT-3F4

      tite4(P Page?tite4

      ?head4

      body4  h!4Meo 5ordK?h!4

      form name actionactionn.jsp methodpost4

     ,nter (ource2input namesource typete6t ?4br?4

    ,nter %estination2input namedestination typete6t ?4br?4

  • 8/20/2019 Soa Lab Manuals

    17/28

     input nameo$ typesubmit vaue ?4

    ?form4

      ?body4

    ?htm4

    A3"i(5)

    J;page contentTypete6t?htm page,ncodingUT-3FJ4

    K%"TLP, MT: PUBI" 3??5#"??%T% MT: &.H1 Transitiona??,N

      http2??www.w#.org?T*?htm&?oose.dtd4

    htm4

      head4

      meta http3eEuiv"ontent3Type contentte6t?htm9 charsetUT-3F4

      tite4(P Page?tite4  ?head4

      body4  h!4Meo 5ordK?h!4

      J

     (tring a1reEuest.getParameter

  • 8/20/2019 Soa Lab Manuals

    18/28

     java.ang.(tring source a19

     java.ang.(tring destination b19

    ?? T% process resut here java.ang.(tring resut port.getBus

  • 8/20/2019 Soa Lab Manuals

    19/28

    CREATION OF A BPEL MODULE AND A COMPOSITE APPLICATION

    Aim2

    "reate a (A project with BP, :odue to compose a web service.

    (T,P( T "*,AT, A BP, :%U,

    C!%."i(g . (%/ BPEL M'l% P!5%3"

    The foowing sections use the (ynchronous sampe project8 and provide step3by3step

    directions for creating a simpe BP, modue project8 using the (ynchronous sampe

     project.

    T C!%."% . BPEL M'l% P!5%3"

    1. In the NetBeans I%,8 choose -ie 4 New Project.

    The New Projects wiOard appears.

    !. Under "ategories8 seect (ervice riented Architecture.

    #. Under Projects8 seect BP, :odueand cic$ Ne6t.

    &. In the Name and ocation page8 enter the project name

  • 8/20/2019 Soa Lab Manuals

    20/28

    '. "ic$ -inish.

    The Projects window now contains a project node for the BP, :odue project.

    C!%."i(g . BPEL P!3%)) U)i(g "#% BPEL D%)ig(%!

     Now that you have created your W: (chema and 5(% %ocument8 you can createyour BP, process.

    T C!%."% "#% BPEL P!3%))

    1. In the Projects window8 e6pand your BP, modue project node8 right3cic$ theProcess -ies node8 and choose New 34 BP, Process.

    The New BP, Process diaog bo6 appears.

  • 8/20/2019 Soa Lab Manuals

    21/28

    !. ,nter a name for the process fie name

  • 8/20/2019 Soa Lab Manuals

    22/28

    #. Add a partner in$ to the BP, Process.

    a. In the Projects window8 e6pand your projectRs Process -ies node andseect the .wsd fie

  • 8/20/2019 Soa Lab Manuals

    23/28

    &. Add a *eceive activity to the BP, Process.a. -rom the 5eb (ervice section of the Paette window8 seect the *eceive

    activity.

     b. %rag the *eceive activity to the Meo5ordProcess process bo6 in the%esign view canvas8 between the Process (tart and the Process ,nd

    activities.

    The *eceive1 activity is added to the process bo6.c. "ic$ the *eceive1 activityRs ,dit icon.

    The *eceive1 Property ,ditor appears.

    d. n the :ain tab8 change the vaue in the Name fied to )".!".e. -rom the Partner in$ drop3down ist8 choose P.!"(%!Li(78.

    The I%, popuates the peration fied with New5(%peration.

    f. "ic$ the "reate button ne6t to the Input 0ariabe -ied.

    The New Input 0ariabe diaog bo6 appears.g. "ic$ to accept the defaut vaues.

    h. "ic$ to cose the *eceive1 Property ,ditor.

    The %esign view dispays the new connection between Partnerin$1 and the (tart

    activity in the process bo6.

  • 8/20/2019 Soa Lab Manuals

    24/28

    '. Add a *epy activity to the BP, Process.

    a. (eect the *epy activity in the 5eb (ervice section of the Paette. %ragand drop the *epy to the prompt between the (tart activity and theProcess ,nd activity in the process bo6 on the design view canvas.

    A *epy1 activity is added to the design view canvas.

     b. "ic$ the *epy1 activityRs ,dit icon.The *epy1 Property ,ditor appears.

    c. n the :ain tab8 change the vaue in the Name fied to ,nd.

    d. -rom the Partner in$ drop3down ist8 choose Partnerin$1.The I%, popuates the peration fied with New5(%peration.

    e. To create anew output variabe8 ma$e sure that Norma *esponse is

    seected8 and cic$ the "reate button ne6t to the Input 0ariabe -ied.

    The New Input 0ariabe diaog bo6 appears. "ic$ to accept the defaut vaues.f. "ic$ to cose the *epy1 Property ,ditor.

    The %esign view dispays the new connection between the ,nd activity in the process

     bo6 and Partnerin$1.

  • 8/20/2019 Soa Lab Manuals

    25/28

    ). Add a Assign activity to the BP, Process.

    a. (eect the Assign activity in the Basic Activities section of the Paette.%rag and drop the Assign to the prompt between the (tart activity and the

    ,nd activity in the process bo6 on the design view canvas.The Assign1 activity is added to the design view canvas. b. (eect the Assign1 activity and cic$ the :apper button on the editors

    toobar.

    The BP, :apper appears.

    c. :ap the paramA node under 0ariabes 34 New5(%perationIn 34inputType in the utput pane of the BP, :apper8 to the paramA node

    under 0ariabes 34 New5(%perationut 34 resutType in the Input

     pane of the :apper. To do this8 seect theparamA node under 0ariabes 34 New5(%perationIn 34 inputType in the utput pane8 and drag your

    cursor to the paramA node under 0ariabes 34 New5(%perationut 34

    resutType in the Input pane.This assignment copies the input statement into the output.

  • 8/20/2019 Soa Lab Manuals

    26/28

    +. To save your changes cic$ the (ave A icon in the I%, menu bar.

    C!%."i(g . Cm)i"% Ali3."i( P!5%3"

    A BP, :odue project is not directy depoyabe. Lou must first add a BP, :odue

     project8 as a BI modue8 to a "omposite Appication project. Lou can then depoy the

    "omposite Appication project. %epoying the project ma$es the service assembyavaiabe to the appication server and enabes its service units to run.

    T C!%."% . N%/ Cm)i"% Ali3."i( P!5%3"

    1. "hoose -ie 4 New Project

  • 8/20/2019 Soa Lab Manuals

    27/28

    &. pen the (ervices window and e6pand (ervers 34 /ass-ish 0! 34 BI 34 (ervice

    Assembies to see your new depoyed (ervice Assemby.

    If you do not see the depoyed project8 right3cic$ the (ervice Assembies node andchoose *efresh.

    T%)"i(g "#% Cm)i"% Ali3."i(

    Lou can test your "omposite Appication project by adding test cases8 binding to the

    operation8 suppying input8 and then using the tester.

    T%)" "#% H%llW!lAli3."i( Cm)i"% Ali3."i( P!5%3"

    1. In the Projects window8 e6pand the Meo5ordAppication project node8 right3

    cic$ the Test node8 and choose New Test "ase.

    The New Test "ase wiOard opens.

    !. Accept the defaut test case name8 Test"ase18 and cic$ Ne6t.#. -rom the (eect the 5(% %ocument page8 e6pand the Meo5ord 3 Proecss

    -ies node8 seect (ynchronous.wsd8 and cic$ Ne6t.

    &. -rom the (eect the peration to Test page8 seect the peration1 and cic$ -inish.A new Test"ase1 node is added under the projectRs Test node in the Projects window8

    containing two subnodes8 Input and utput.

    The (ource ,ditor appears containing the Input fie8 Input.6m

    N"% 9

    If the (ource ,ditor does not contain a tab for Input.6m8 doube3cic$ the Input node in

    the Projects window to open the fie.

    '. -rom the Input.6m tab of the (ource ,ditor8 do the foowing2a. ocate the ine2

    syn2paramA4XstringXsyn2paramA4

     b. *epace XstringX with Meo 5ord8 so that the ine appears as foows2

    syn2paramA4Meo 5ordsyn2paramA4

  • 8/20/2019 Soa Lab Manuals

    28/28

    c. -rom the NetBeans I%, menu bar8 cic$ (ave A.

    ). In the Projects window8 doube3cic$ the utput node under Test 34 Test"ase1.

    utput.6m is opened in the (ource ,ditor. Initiay8 utput.6m is empty unti the firsttest run popuates the fie.

    +. In the Projects window8 right3cic$ the Test"ase1 node and choose *un from the pop3up menu.

    5hen the verwrite ,mpty utput diaog bo6 appears8 cic$ Les to accept new output.

    The first test run popuates the utput.6m fie dispayed in the (ource ,ditor.

    The test compares the output to the contents of the output fie. Because the first run of thetest has nothing to compare itsef to8 the first test fais. (ubseEuent test runs wi compare

    their output with the contents of utput.6m and shoud succeed.

    F. *un the test again.The test case is compared to the current output fie and succeeds.