A PREMIER INSTITUTION FOR PROFESSIONAL EDUCATION APPROVED BY AICTE, NEW DELHI & AFFILIATED TO ANNA UNIVERSITY, CHENNAI AN ISO 9001:2008 CERITIFIED INSISTUITON BY DNV NETHERLAND & ACCREDITED BY NBA
(As per Anna University, Chennai – Curriculum R 2008)
!"
!"
S.K.P ENGINEERING COLLEGE Tiruvannamalai– 606 611 DEPARTMENT OF INFORAMTION TECHNOLOGY
Doc. No. : IT Lab
Rev.No.
: 00
Date
: 07.07.11
IT2406 - SERVICE ORIENTED ARCHITECTURE LAB
SERVICE ORIENTED ARCHITECTURE LAB LAB MANUAL Subject Code : IT2406 Sem / Branch : VII - IT A & B (As per Anna University, Chennai – Curriculum R 2008)
Prepared by : MANIMARAN.M
& RAMACHANDRAN.A
Approved by: HOD/IT
S.K.P ENGINEERING COLLEGE Tiruvannamalai– 606 611 DEPARTMENT OF INFORAMTION TECHNOLOGY
Doc. No. : IT Lab
Rev.No.
: 00
Date
: 07.07.11
IT2406 - SERVICE ORIENTED ARCHITECTURE LAB
SERVICE ORIENTED ARCHITECTURE LAB LAB MANUAL Subject Code : IT2406 Sem / Branch : VII - IT A & B (As per Anna University, Chennai – Curriculum R 2008)
Prepared by : MANIMARAN.M
& RAMACHANDRAN.A
Approved by: HOD/IT
S.K.P ENGINEERING COLLEGE Tiruvannamalai– 606 611 DEPARTMENT OF INFORAMTION TECHNOLOGY
Doc. No. : IT Lab
Rev.No.
: 00
Date
: 07.07.11
IT2406 - SERVICE ORIENTED ARCHITECTURE LAB
B.Tech. INFORMATION TECHNOLOGY
SEMESTER VII (Applicable to the students admitted from the Academic year 2008_2009 onwards)
IT2406
SERVICE ORIENTED ARCHITECTURE LAB
LTPC 0 0 3 2
1. Develop at least 5 components such as Order Processing, Payment Processing, using .NET component technology.
etc.,
2. Develop at least 5 components such as Order Processing, Payment Processing, using EJB component technology.
etc.,
3. Invoke .NET components as web services. 4. Invoke EJB components as web services. 5.Develop a Service Orchestration Engine (workflow) using WS-BPEL and implement service composition. For example, a business process for planning business travels will invoke several services. This process will invoke several airline companies (such as American Airlines, Delta Airlines etc. ) to check the airfare price and buy at the lowest price. 6. Develop a J2EE client to access a .NET web service. 7. Develop a .NET client to access a J2EE web service. TOTAL = 45 PERIODS
Prepared by : MANIMARAN.M
& RAMACHANDRAN.A
Approved by: HOD/IT
S.K.P ENGINEERING COLLEGE Tiruvannamalai– 606 611 DEPARTMENT OF INFORAMTION TECHNOLOGY
Doc. No.
: IT Lab
Rev.No.
: 00
Date
: 07.07.11
IT2406 - SERVICE ORIENTED ARCHITECTURE LAB
Requirement for a batch of 30 students LIST OF EQUIPMENTS: Hardware: CPU:- (As Server) Processor (Core 2 Quad or equivalent) with good speed, 2GBRAM, 300GBHDD Software: 1).NET framework (MS Academic Alliance)(or)Express Edition 2) J2EE framework free download 3) OS – Windows or Linux
Available for a batch of 30 students 1.
SOFTWARE
2.
- 30
Windows Operating System Visual Studio 2005 for .NET Framework Netbeans IDE 6.0 for J2EE Framework
Hardware Processor Ram Hard disk Monitor Keyboard Mouse LAN
Prepared by : MANIMARAN.M
- 30 -
Pentium Dual core 2.70 GHz 1 GB 160 GB LCD Monitor 101 Keyboard Ps/2 mouse 100Mbps
& RAMACHANDRAN.A
Approved by: HOD/IT
S.K.P ENGINEERING COLLEGE Tiruvannamalai– 606 611 DEPARTMENT OF INFORAMTION TECHNOLOGY
Doc. No.
: IT Lab
Rev.No.
: 00
Date
: 07.07.11
IT2406 - SERVICE ORIENTED ARCHITECTURE LAB
S. No
Page No
Table of Contents
8
Develop at least 5 components such as Order Processing, Payment Processing, etc., using .NET component technology. Develop at least 5 components such as Order Processing, Payment Processing, etc., using EJB component technology. Invoke .NET components as web services. Invoke EJB components as web services. Develop a Service Orchestration Engine (workflow) using WSBPEL and implement service composition. For example, a business process for planning business travels will invoke several services. This process will invoke several airline companies (such as American Airlines, Delta Airlines etc. ) to check the airfare price and buy at the lowest price. Develop a J2EE client to access a .NET web service. Develop a .NET client to access a J2EE web service. Content Beyond the Syllabus Develop and execute WS-BPEL V2.0 business processes using the Eclipse BPEL plug-in.
9
Asp.net website using Visual Web Developer 2008.
1 2 3 4
5
6 7
Prepared by : MANIMARAN.M
& RAMACHANDRAN.A
1 7 15 20
30
44 52
61 71
Approved by: HOD/IT
EX.NO: 1 DEVELOPING A COMPONENTS USING .NET COMPONENT TECHNOLOGY FOR INVOICE PROCESSING AIM:
To develop an application for implementing a co mponents using .NET component technology for invoice processing using Visual Studio 2005. Creating the component Project Type : Visual Basic Template : Class Library Project Creating Consumer Application Project Type : Visual Basic Template : Windows Application Software Requirements:
Microsoft Visual Studio 2005
PROCEDURE: Creating the Component 1. Start Visual Studio .NET and open the New Project dialog box, select new Class Library project. Name the project as ServerTime 2. Change the name of the class from Class1 to ServerTime. 3. Enter the following code into the new ServerTime class module: Public Class ServerTime Private mdtTime As DateTime ReadOnly Property TimeStamp() As String Get mdtTime = Now() Return CStr(mdtTime) End Get End Property End Class You will now compile this ServerTimer class as a DLL by clicking Build on the Debug menu or by using the Ctrl+Shift+B keystroke combination. The DLL that results from the build command is placed into the directory C:\My Documents\Visual Studio 2005\Projects Create a DLL Consumer Application Follow these steps to create the consumer application: Step1: Start Visual Studio .NET, select Windows Application as the new project type, and name the project Invoice. Design the form as shown below.
1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step2: Changing name to textboxes QTY Textbox - > Qty1,Qty2,Qty3 ITEM Textbox - > Item1,Item2,Item3 UNIT PRICE Textbox - >UPric1,UPrice2,UPrice3 PRICE Textbox -> Price1,Price2,Price3 SubTotal Textbox->Subtotal Tax Textbox->Tax Total Textbox->Total Purchase Time->Ptime Like that check the names with the following coding… Step4:Enter the following coding in Public class form1 Public Class Form1 ' Declaring the quantity to buy Dim qtyone As Decimal Dim qtytwo As Decimal Dim qtythree As Decimal ' Declaring the item that you are going to buy Dim itemone As String Dim itemtwo As String Dim itemthree As String 'Declaring the price for 1 item Dim unitpriceone As Decimal Dim unitpricetwo As Decimal Dim unitpricethree As Decimal ' Declaring the price for each one Dim priceunitone As Decimal Dim priceunittwo As Decimal Dim priceunitthree As Decimal
Step4:Enter the following coding in Button1_click(Double click on calculate button)
2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim st As ServerTime.ServerTime st = New ServerTime.ServerTime() Ptime.Text = st.TimeStamp Price1.Visible = True Price2.Visible = True Price3.Visible = True SubTotal.Visible = True taxlabel.Visible = True Total.Visible = True reportlabel.Visible = True sublabel.Visible = True taxlabel.Visible = True totallabel.Visible = True Ptime.Visible = True Ptimelabel.Visible = True seelabel.Visible = True Tax.Visible = True ' setting the quantity to be in those textboxes qtyone = Val(Qty1.Text) qtytwo = Val(Qty2.Text) qtythree = Val(Qty3.Text) ' setting itemone = itemtwo = itemthree
the items to be in those textboxes Item1.Text Item2.Text = Item3.Text
' setting the price/ 1 item to be in those textboxes unitpriceone = Val(UPrice1.Text) unitpricetwo = Val(UPrice2.Text) unitpricethree = Val(UPrice3.Text) ' setting the price / each one to be in those textboxes priceunitone = Val(Price1.Text) priceunittwo = Val(Price2.Text) priceunitthree = Val(Price3.Text) ' calculating Price1.Text = Price2.Text = Price3.Text =
the price for each one unitpriceone * qtyone unitpricetwo * qtytwo unitpricethree * qtythree
' calculating the subtotal SubTotal.Text = (unitpriceone * qtyone) + (unitpricetwo * qtytwo) + (unitpricethree * qtythree) ' calculating the Tax Tax.Text = 0.4 * (Val(Subtotal.Text)) ' calculating the total price Tax + SubTotal 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Total.Text = (Val(Tax.Text) + Val(SubTotal.Text)) reportlabel.Text = "Thankyou for purchasing the following items: " & Chr(13) & " Invoice No is:&" & Val(INo.Text) & Chr(13) & "You have purcheased: " & qtyone & " of " & itemone & " =&" & Val(Price1.Text) & Chr(13) & "You have purcheased: " & qtytwo & " of " & itemtwo & " =&" & Val(Price2.Text) & Chr(13) & "You have purcheased: " & qtythree & " of " & itemthree & " =&" & Val(Price3.Text) End Sub End Class
Step5: You need to set a reference to the ServerTime DLL so tat this form will be able to consume the components services. Do this by following the steps below. 1. To open the Add Reference dialog box , on the Project menu, click Add Reference.
2. Click Browse tab to locate the component DLL built in the preceding section.The dll file is located in this directory C: \My Documents\Visual Studio 2005\Projects\ServerTime\ServerTime\bin\Debug
4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
OUTPUT:
RESULT: Thus the application for implementing a components using .NET component technology for invoice processing is build and debugged success fully.
6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Ex.No. 2. DEVELOPING A COMPONENTS FOR INVOICE PROCESSING USING EJB COMPONENT TECHNOLOGY Aim:
To create projects for deploying a component using EJB component technology for invoice processing using NetBeans IDE. Categories
: Enterprise
Project
: Enterprise Application
Server
: Glass Fish V2
Java EE Version
: Java EE 5
Software Required:
1. JDK 1.6 2. NetBeans IDE 6.0 Procedure: Step1: o Open NetBeans IDE 6.0 then File->New Project, Choose Project categories as
Enterprise and project as Enterprise Application then click Next >.
o Give Project Name as “Invoice” and then click then Click Finish.
7
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step2: Servlet Creation 1. Right click on “Invoice-war” then New->Servlet and give class name as Invoiceser , package name as Invoicepack click Finish.
8
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
2. “Invoiceser.java” will open, delete all the coding and type the following coding. package Invoicepack; import java.io.*; import java.net.*; import javax.servlet.*; import javax.servlet.http.*; public class Invoiceser extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); int q1=Integer.parseInt(request.getParameter("qone")); int q2=Integer.parseInt(request.getParameter("qtwo")); int q3=Integer.parseInt(request.getParameter("qthree")); int up1=Integer.parseInt(request.getParameter("uone")); int up2=Integer.parseInt(request.getParameter("utwo")); int up3=Integer.parseInt(request.getParameter("uthree")); int p1=q1*up1; int p2=q2*up2; int p3=q3*up3; int st=p1+p2+p3; double t=0.4; double tax=(t*st); double total=tax+st; out.println("
SKP SUPER MARKET
"); out.println("
"); out.println("
INVOICE USING EJB
"); out.println("
"); out.println("
Price1 ="+p1); out.println("
"); out.println("Price2 ="+p2); out.println("
"); out.println("Price3 ="+p3); out.println("
"); out.println("
"); out.println("Subtotal="+st); 9
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
out.println("
"); out.println("Tax="+tax); out.println("
"); out.println("
"); out.println("Total="+total); out.println("
"); out.println("
"); out.println("Thanks for purchasing
"); } } Step3: Index Page Creation
1. Double Click on “Invoice-war” then double click on “webpages” finally double click on “index.jsp”.
2. Index.jsp page will open in that type the following html code. <%@page contentType="text/html" pageEncoding="UTF-8"%> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> INVOICE PROCESSING
SKP SUPER MARKET
INVOICE USING EJB
Step4: Run the Application 1 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
1. Save the projects then right click on index.jsp, click Run File to run this project.
2.
Invoice form will be displayed in explorer.
2 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
OUTPUT:
RESULT:
Thus the projects for deploying a component using EJB component technology for invoice processing is deployed and debugged successfully.
Ex.No. 3. Invoke .NET components as web services. Aim: 3 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
To develop a web services to invoke .NET component using Visual Studio 2005 ASP.Net Application project. Project Type Template Software Required:
: Visual Basic : ASP.NET Application Project
Microsoft Visual Studio 2005 Update – Service Pack 1(VS80SP1)
Procedure: Step1: Creating a New Project 1. Select File->New Project within the Visual Studio 2005 IDE. This will bring up the New Project dialog. Click on the “Visual Basic” node in the tree-view on the left hand side of the dialog box and choose the "ASP.NET Web Application" icon: Then give Project name as Webservices click OK
2. Right Click on Default.aspx in solution explorer and click View Designer
4 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step2: Design the Components 1. Design the form as shown below.
2. Double click on Button to enter coding. And Enter the following code on it. Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim add As Integer Dim subt As Integer Dim mul As Integer Dim div As Integer add = CInt(TextBox1.Text) + CInt(TextBox2.Text) subt = CInt(TextBox1.Text) - CInt(TextBox2.Text) mul = CInt(TextBox1.Text) * CInt(TextBox2.Text) div = CInt(TextBox1.Text) / CInt(TextBox2.Text) Label3.Text = "Addition of" & Val(TextBox1.Text) & " and " & Val(TextBox2.Text) & " is: " & add
5 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Label4.Text = "Subtraction of" & Val(TextBox1.Text) & " and " & Val(TextBox2.Text) & " is: " & subt Label5.Text = "Multiplication of" & Val(TextBox1.Text) & " and " & Val(TextBox2.Text) & " is: " & mul Label6.Text = "Division of" & Val(TextBox1.Text) & " and " & Val(TextBox2.Text) & " is: " & div End Sub End Class
Step3: Building the webservices
1. Right click on default.aspx and click view markup means you will see the asp code already generated for this application.
2. Right click on default.aspx and click Set as start page.
3. Finally Build the Application from menu tab or press ctrl+shift+B. 4. After Build succeeded then start debugging. Or press F5 to Debug 6 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
5. ASP.NET Development Server Starts automatically.
7 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
OUTPUT:
RESULT:
Thus the web services to invoke .NET component using Visual Studio 2005 ASP.Net Application project is developed and debugged.
8 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Ex.No 4. Invoke EJB components as web services. Aim:
To develop a web services to invoke EJB component using Netbeans. Categories
: Web
Project
: Web Application
Server
: Glass Fish V2
Java EE Version
: Java EE 5
Software Required:
1. JDK 1.6 2. NetBeans IDE 6.0 Procedure: 1. Creating a Web Service Step1:Choosing a Container 1. Choose File > New Project (Ctrl-Shift-N). Select Web Application from the category EJB and project as Web Application.
2.
Name the project CalculatorWSApplication. Select a location for the project and Select your server and Java EE version and click Finish.
9 1
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step 2: Creating a Web Service from a Java Class 1. Right-click the CalculatorWSApplication node and choose New > Web Service.
2. Name the web service CalculatorWS and type org.me.calculator in Package. Leave Create Web Service from Scratch selected.
3. Click Finish. The Projects window displays the structure of the new web service and the source code is shown in the editor area. Step 3: Adding an Operation to the Web Service To add an operation to the web service: 1. Change the Design View in the Editor.
0 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
2. Click Add Operation in either the visual designer or the context menu. A dialog box appears where you can define the new operation. 3. In the upper part of the Add Operation dialog box, type add in Name and type int in the Return Type drop-down list. In the lower part of the Add Operation dialog box, click Add and create a parameter of type int named a1. Then click Add again and create a parameter of type int called a2
4. Click OK at the bottom of the Add Operation dialog box. The visual designer now displays the following:
1 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
5. Click Source and view the code that you generated in the previous steps.
6. In the editor, extend the skeleton add operation to the following (changes are in bold): @WebMethod public int add(@WebParam(name = "i") int i, @WebParam(name = "j") int j) { int ad = a1 + a2; return ad; }
Step4: Deploying and Testing the Web Service To test successful deployment to a server: 1. Right-click the project and choose Deploy. The IDE starts the application server, builds the application, and deploys the application to the server. You can follow the progress of these operations in the CalculatorWSApplication (run-deploy) and the GlassFish server tabs in the Output view. 2. In the IDE's Projects tab, expand the Web Services node of the CalculatorWSApplication project. Right-click the CalculatorWS node, and choose Test Web Service.
2 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
The IDE opens the tester page in your browser, if you deployed a web application to the GlassFish server. If you deployed to the GlassFish server, type two numbers in the tester page, as shown below:
The sum of the two numbers is displayed: If you click add button
3 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
2. Consuming the Web Service Client : JSP Page in Web Application 1. Choose File > New Project (Ctrl-Shift-N). Select Web Application from the Java Web category. Name the project CalculatorWSJSPClient. Click Finish.
4 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
2. Right-click the CalculatorWSJSPClient node and choose New > Web Service Client.
3. Select Project as the WSDL source. Click Browse. Browse to the CalculatorWS web service in the CalculatorWSApplication project. When you have selected the web service,
5 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
click OK.
4. Leave the other settings at default and click Finish. The Projects window displays the new web service client, as shown below:
5. In the Web Service References node, expand the node that represents the web service. The add operation, which you will invoke from the client, is now exposed. 6. Drag the add operation to the client's index.jsp page, and drop it below the H1 tags. The code for invoking the service's operation is now generated in the index.jsp page, as you can see here: <%-- start web service invocation --%>
<% try { org.me.calculator.CalculatorWSService service = new org.me.calculator.CalculatorWSService(); org.me.calculator.CalculatorWS port = service.getCalculatorWSPort(); // TODO initialize WS operation arguments here int a1 = 0; int a2 = 0; // TODO process result here int result = port.add(a1, a2); out.println("Result = "+result); } catch (Exception ex) { // TODO handle custom exceptions here } 6 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
%> <%-- end web service invocation --%>
Change the value for i and j from 0 to other integers, such as 3 and 4. Finally The Index page look like this. <%-Document : index Created on : Aug 11, 2011, 10:36:50 AM Author : sysadmin --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> WEB SERVICES CLIENT
<%-- start web service invocation --%>
<% try { org.me.calculator.CalculatorWSService service = new org.me.calculator.CalculatorWSService(); org.me.calculator.CalculatorWS port = service.getCalculatorWSPort(); // TODO initialize WS operation arguments here int a1 = 5; int a2 = 8; // TODO process result here int result = port.add(a1, a2); out.println("Result = "+result); } catch (Exception ex) { // TODO handle custom exceptions here } %> <%-- end web service invocation --%>
Webservice Invoking Using EJB TECHnolgy
7. Right-click the project node and choose Run. The server starts, if it wasn't running already. The application is built and deployed, and the browser opens, displaying the calculation result:
7 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Output:
RESULT:
Thus the web services to invoke EJB component using Netbeans is developed and debugged.
8 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Ex.No. 5. Develop a Service Orchestration Engine (workflow) using WS-BPEL and implement service composition. Aim: To Develop a Service Orchestration Engine (workflow) usi ng WS-BPEL and implement service composition using Netbeans. WS – Web Services , BPEL - Business Process Execution Language To Create BPEL
Categories
: SOA
Project
: BPEL Module
To Create BPEL
Categories
: SOA
Project
: Composite Application
STEPS TO CREATE A BPEL MODULE Creating a new BPEL Module Project The following sections use the Synchronous sample project, and provide step-by-step directions for creating a simple BPEL module project, using the Synchronous sample project. To Create a BPEL Module Project 1. In the NetBeans IDE, choose File > New Project. The New Projects wizard appears. 2. Under Categories, select Service Oriented Architecture. 3. Under Projects, select BPEL Module and click Next.
4. In the Name and Location page, enter the project name as “ MyBPEL”
9 2
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
5. Click Finish. Creating a BPEL Process Using the BPEL Designer The Projects window now contains a project node for the BPEL Module project.
To Create the BPEL Process 1. In the Projects window, expand your BPEL module project node, right-click the Process Files node, and choose New -> BPEL Process.The New BPEL Process dialog box appears.
2. Enter a name for the process file name as “ Sample”, and click Finish. 0 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
To Create the WSDL Process 1. In the Projects window, right-click the Process Files node, and choose New -> WSDL Document. The New WSDL Document dialog box appears.
2. Enter a name for the WSDL Document name as “ myproject”and click next upto Finish is shown and then Click Finish. To Create the XML Process 1. In the Projects window, right-click the Process Files node, and choose New -> XML Schema. The New XML Schema dialog box appears.
2. Enter a name for the XML Schema name as “ myproject”and click Finish
1 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
3. Add a partner link to the BPEL Process. a. In the Projects window, expand your project's Process Files node and select the .wsdl file (myproject.wsdl) b. Drag the WSDL file from the Projects window to the left side of the Design view canvas.
The IDE provides visual prompts to show you where you can drop the selection.
2 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Click ok. The BPEL Editor adds a partner link to the canvas.
3 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
4. Add a Receive activity to the BPEL Process. a. From the Web Service section of the Palette window, select the Receive activity. b. Drag the Receive activity to the Sample process box in the Design view canvas, between the Process Start and the Process End activities. The Receive1 activity is added to the process box. c. Click the Receive1 activity's Edit icon. The Receive1 Property Editor appears. d. On the Main tab, change the value in the Name field to start. e. From the Partner Link drop-down list, choose PartnerLink1.
The IDE populates the Operation field with NewWSDLOperation. f. Click the Create button next to the Input Variable Field. The New Input Variable dialog box appears. 4 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
g. Click OK to accept the default values. h. Click OK to close the Receive1 Property Editor. The Design view displays the new connection between PartnerLink1 and the Start activity in the process box.
5. Add a Reply activity to the BPEL Process. a. Select the Reply activity in the Web Service section of the Palette. Drag and drop the Reply to the prompt between the Start activity and the Process End activity in the process box on the design view canvas. A Reply1 activity is added to the design view canvas. b. Click the Reply1 activity's Edit icon. The Reply1 Property Editor appears. c. On the Main tab, change the value in the Name field to End. d. From the Partner Link drop-down list, choose PartnerLink1. The IDE populates the Operation field with NewWSDLOperation. e. To create anew output variable, make sure that Normal Response is selected, and click the Create button next to the Input Variable Field. The New Input Variable dialog box appears. Click OK to accept the default values. f. Click OK to close the Reply1 Property Editor. The Design view displays the new connection between the End activity in the process box and PartnerLink1.
5 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
6. Add a Assign activity to the BPEL Process. a. Select the Assign activity in the Basic Activities section of the Palette. Drag and drop the Assign to the prompt between the Start activity and the End activity in the process box on the design view canvas. The Assign1 activity is added to the design view canvas. b. Select the Assign1 activity and click the Mapper button on the editors toolbar. The BPEL Mapper appears.
This assignment copies the input statement into the output.
7. To save your changes click the Save All icon in the IDE menu bar. ********Creating a Composite Application Project**************************************** 6 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
A BPEL Module project is not directly deployable. You must first add a BPEL Module project, as a JBI module, to a Composite Application project. You can then deploy the Composite Application project. Deploying the project makes the service assembly available to the application server and enables its service units to run. To Create a New Composite Application Project 1. Choose File > New Project (Ctrl-Shift-N). 2. In the Categories list choose Service Oriented Architecture, in the Projects list choose Composite Application, and click Next. 3. In the Name and Location page, change the project name to SampleApplication, and s pecify the location of project files. 4. To set the new Composite Application the main project as main, leave the Set as M ain Project checkbox selected, and click Finish. 5. To add the BPEL Module as a JBI module to the Composite Application project, right-click the new SampleApplication and choose Add JBI Module.
The Select Project dialog box opens. 6. Select the MyBPEL project you created earlier and click Add Project JAR Files.
The Select Project dialog box closes and the HelloWorld.jar file is added to the JBI Modules node of the HelloWorldApplication Composite Application Building and Deploying the Composite Application Project Building a project compiles the BPEL source file and packages the BPEL file and web service artifacts, including WSDL and XSD files, into a JAR archive. Deploying the project compiles the files in the Composite Application project, packages the compiled BPEL and related web service artifacts (including WSDL and XSD files) into an archive, and deploys them to the Application Server. To Build and Deploy the Composite Application Project 1. Right-click the SampleApplication project's node, and choose Build. When the build is complete the Output window reports Build Successful. 2. Right-click the SampleApplication project's node, and choose Deploy. 7 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
3. Deployment has succeeded when you see a Build successful message in the GlassFish tab of the Output window. 4. Open the Services window and expand Servers -> GlassFish V2 -> JBI -> Service Assemblies to see your new deployed Service Assembly. If you do not see the deployed project, right-click the Service As semblies node and choose Refresh.
Testing the Composite Application You can test your Composite Application project by adding test cases, binding to the operation, supplying input, and then using the tester. Test the HelloWorldApplication Composite Application Project 1. In the Projects window, expand the HelloWorldApplication project node, right-click the Test node, and choose New Test Case. The New Test Case wizard opens. 2. Accept the default test case name, TestCase1, and click Next. 3. From the Select the WSDL Document page, and click
next. 4. From the Select the Operation to Test page,
and click Finish. 8 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
A new TestCase1 node is added under the project's Test node in the Projects window, containing two subnodes, Input and Output. The Source Editor appears containing the Input file, Input.xml Note – If the Source Editor does not contain a tab for Input.xml, double-click the Input node in the Projects window to open the file.
5. From the Input.xml tab of the Source Editor, do the following: a. Locate the line: ?string? b. Replace ?string? with WS-BPEL USING NET BEAN, so that the line appears as follows: WS-BPEL USING NET BEAN c. From the NetBeans IDE menu bar, click Save All.
6. In the Projects window, double-click the Output node under Test -> TestCase1. Output.xml is opened in the Source Editor. Initially, Output.xml is empty until the first test run populates the file. 7. In the Projects window, right-click the TestCase1 node and choose Run from the pop-up menu. When the Overwrite Empty Output dialog box appears, click Yes to accept new output. The first test run populates the Output.xml file displayed in the Source Editor.
The test compares the output to the contents of the output file. Because the first run of the test has nothing to compare itself to, the first test fails. Subsequent test runs will compare their output with the contents of Output.xml and should succeed. 8. Run the test again. The test case is compared to the current output file and succeeds.
9 3
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
OUTPUT: Test Case Creation
Input.xml
Output.xml
Failed Message
0 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Test Case Passed Message
Output.xml
RESULT:
Thus the Composite application is developed using WS-BPEL and implemented service composition using Netbeans. Ex.No.6 Develop a J2EE client to access .NET Web Service Aim:
To Develop a J2EE Client to access .Net web service using Visual Studio 2005. To Develop a Web Service 1 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Language Templates
: Visual C# : ASP.NET Web Service
To Develop a J2EE Client Category : Java Projects : Java Application Software Required:
Visual Studio 2005 SQL Server 2005 Netbeans IDE 6.0.1
PROCEDURE 1. Develop a .Net Web Service Step1:Creating a web service First let us create a new project in Visual Studio.NET for web service. Then add classes related to data access and write code for Web Service methods. 1. Start Visual studio.NET 2008/2005 2. Select File->New->Website. Select ASP.NET Web service as the type of the project and enter InventoryWS as the name of the project. Visual Studio provides Service.cs and Service.asmx files along with others. Delete these two files. 3. We add a new web service to the project using Website -> Add new item -> Web Service and enter name as InventoryService. Visual Studio creates InventoryService.aspx in root directory and InventoryService.cs in App_Code directory. We will write code for web service later. First let us create DAL to access database. Step2:Creating Data Access Layer Data Access Layer is set of classes used to access database. We centralize the entire data access to DAL. In this project we create two classes to represent data. I am using PRODUCTS table, which is created by me in MSDB database of Sql Server Express Edition. You have to do the same in your system. Create PRODUCTS table with the following structure. PRODID - int (Primary key) prodname - varchar(50) price - money qoh - int remarks - varchar(200) catcode - varchar(10)
Add some rows to PRODUCTS table. Add a class to the project using Website-> Add New Item -> Class and enter name as Product. Here is the code for Product.cs. using System; using System.Web.Services; using System.Runtime.Serialization; 2 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
public class Product { private int prodid, qty; private string name, remarks; private double price; public int Qty { get { return qty; } set { qty = value; } } public int Prodid { get { return prodid; } set { prodid = value; } } public string Remarks { get { return remarks; } set { remarks = value; } } public string Name { get { return name; } set { name = value; } } public double Price { get { return price; } set { price = value; } } } Add connection string in connectionStrings section of web.config as follows. Add Database.cs class and enter the following code. using System.Web.Configuration; public class Database { public static string ConnectionString { get 3 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
{ return WebConfigurationManager.ConnectionStrings["msdbcs"].ConnectionString; } } } Now create ProductDAL, which contains static methods for operations related to PRODUCTS table as follows. using System; using System.Data; using System.Data.SqlClient; using System.Collections.Generic; public class ProductsDAL { public static List GetAllProducts() { SqlConnection con = new SqlConnection(Database.ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("select * from products", con); SqlDataReader dr = cmd.ExecuteReader(); List products = new List(); while (dr.Read()) { Product p = new Product(); p.Prodid = (int)dr["prodid"]; p.Name = dr["prodname"].ToString(); p.Remarks = dr["remarks"].ToString(); p.Qty = (int)dr["qoh"]; p.Price = Convert.ToDouble(dr["price"]); products.Add(p); } dr.Close(); con.Close(); return products; } public static Product GetProduct(int prodid) { SqlConnection con = new SqlConnection(Database.ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("select * from products where prodid = @prodid", con); cmd.Parameters.AddWithValue("@prodid", prodid); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Product p = new Product(); p.Prodid = (int) dr["prodid"]; p.Name = dr["prodname"].ToString(); 4 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
p.Remarks = dr["remarks"].ToString(); p.Qty = (int) dr["qoh"]; p.Price = Convert.ToDouble (dr["price"]); return p; } else // product not found return null; } } Step 3: Using DAL in Web Service Now let us write code in web service, which makes use of DAL. It is always better you separate data access code into DAL so that other parts of the application do not depend on data access. They access database through DAL. Write the following code in InventoryService.cs. using System; using System.Web.Services; using System.Collections.Generic; [WebService(Namespace = "http://www.srikanthtechnologies.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class InventoryService : System.Web.Services.WebService {
[WebMethod( Description ="Returns Details Of All Products")] public List GetAllProducts() { return ProductsDAL.GetAllProducts(); } [WebMethod(Description = "Returns Details Of A Single Product ")] public Product GetProduct(int prodid) { return ProductsDAL.GetProduct(prodid); } } Now we are through our web service creation. Select web service - InventoryService.asmx and select View In Browser option from context menu (right click). From the page displayed in browser, click on methods and invoke them to test them. Step 5: Custom classes and WSDL Click on Service Description link and you get WSDL for the web service. The following section in that is of interest. 5 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Product class is taken as complexType and its members are placed as sub elements. Collection of Products is taken as an ArrayOfProduct. When you need to access this web service from Java application, we create proxy in Java. Product element will become a class in Java and ArrayOfProduct becomes another class that contains a List of product objects. So, WSDL contains details about custom classes so that clients can generate these classes again on the client. 2.Develop a J2EE Client Step 1:Creating Proxy in Java Now, let us create a proxy in Java to access InventoryService Web Service. 1. Start NetBeans IDE 6.5. 2. Select File->New Project. Select Java in category and Java Application in projects. Click on Next. 3. Enter InventoryClient as the name of the application. Change name of the class in Create Main Class option to Client 4. Click on Finish. 5. Select InvenotryClient project in Projects window. Right click to invoke context menu. Select New->Other. Select Web service in categories and Web Service Client in File Types. 6. In the next window, select WSDL URL radio button (as shown below) and enter the URL at which InventoryService is running. Click on Finish. NetBeans creates required classes to access web service.
6 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step2 :Write code in Java to call web service Once proxy is created then we can write code to access web service methods from Java. In fact, NetBeans can do that for you. Follow the steps given below. 1. Open Client.java 2. Go into main function and click on right button. From context menu select Web Service Client Resources -> Call Web Service Operation... 3. A window pops up with operations in the web service (shown below).
7 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Select GetProduct in InventoryServiceSoap12 section. NetBeans automatically writes code for you. Just assign product id 100 to prodid and change code regarding output, to complete the code. try { // Call Web Service Operation com.srikanthtechnologies.InventoryService service = new com.srikanthtechnologies.InventoryService(); com.srikanthtechnologies.InventoryServiceSoap port = service.getInventoryServiceSoap12(); // TODO initialize WS operation arguments here int prodid = 100; // TODO process result here com.srikanthtechnologies.Product result = port.getProduct(prodid); System.out.println( result.getName()); } catch (Exception ex) { // TODO handle custom exceptions here } Lines in bold are modified by me. The rest is provided by NetBeans. That's all you have to do to call web service created in .NET from Java. 8 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
As you can see, NetBeans created a class Product for which information is provided in WSDL. Follow the same steps to call GetAllProducts method. Change the code as follows. try { // Call Web Service Operation com.srikanthtechnologies.InventoryService service = new com.srikanthtechnologies.InventoryService(); com.srikanthtechnologies.InventoryServiceSoap port = service.getInventoryServiceSoap12(); // TODO process result here com.srikanthtechnologies.ArrayOfProduct result = port.getAllProducts(); List products = result.getProduct(); for(Product p : products) { System.out.println( p.getName() + " : " + p.getPrice()); }
} catch (Exception ex) { // TODO handle custom exceptions here } 4. Now, run Client.java to see whether details of products are displayed from Java program.
Result : Thus the client for accessing the .Net web service is develop and implemented successfully. 7. Develop a .NET client to access a J2EE web service. Aim:
To develop a .net client to access a J2EE Web service Using Netbeans IDE. Category Project
: Web : Web Application 9 4
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Procedure Creating Web Service Step 1: Open Netbeans IDE, which has the Glassfish server by default.
Step 2: In Netbeans take a new web project. Provide the web application name. And select the server name. (Glassfish v2.1 (or) above version) as shown in screen shot and click Finish.
0 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step 3: In the project pane, right click on J2eeweb and select new web service. And give web service name & package name. And click finish.
Step 4: Now in design view of the web services, add the operation and parameters that are going to be used in web services application.
Step 5: Now in source view change the return value null into some string value. JWS.java
package JWSpack; 1 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; /** * * @author Admin MMLAB */ @WebService() public class JWS { /** * Web service operation */ @WebMethod(operationName = "Show") public String Show(@WebParam(name = "name") ,String name) { //TODO write your implementation code here: return "hello "+name; }} Step 6: Finally deploy it on the server and test the web service program. Right Click on JWS and click Test Web Service.
2 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Click the button show means you will see this show Method invocation Method parameter(s) Type
Value
java.lang.String Service
Method returned
java.lang.String : "helloService"
SOAP Request
Service
SOAP Response
3 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
helloService
Creating Client Step 1: Create a client file from web projects and specify the WSDL file of the web services.
Step 2: Create a client environments for the web services in the project. Right Click on j2eeclient and select new and web service client.
4 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step 3: Specify the operation name into web service client resources. By clicking browse and select the web service JWS and click OK
Step4:Create a new jsp file in WEB-INF and name it as client.jsp and click finish.
5 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Enter the code in that client.jsp page. <%@page contentType="text/html" pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> J2EE Web Service >Dot Net Client using J2EE Web Services
<%-- start web service invocation --%>
<% try { jwspack.JWSService service = new jwspack.JWSService(); jwspack.JWS port = service.getJWSPort(); java.lang.String name = "Service"; java.lang.String result = port.show(name); out.println("Result = "+result); } catch (Exception ex) { 6 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
} %> <%-- end web service invocation --%>
Step 5: Execute the web service client file.
7 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Output:
Result:
Thus the .net client is developed for accessing the j2ee web service and implemented successfully.
Content Beyond the Syllabus
8 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
8. Develop and execute WS-BPEL V2.0 business processes using the Eclipse BPEL plug-in Aim: To Develop and execute WS-BPEL V2.0 business processes using the Eclipse BPEL plug-in Software Required 1. Java™ V5.0 or later 2. Tomcat V5.5 or later 3. Eclipse V3.3.x with the following plug-ins installed: o EMF V2.3.x o GEF V3.3.x o DTP STK V1.5.x Creation of a simple BPEL process In this section, we create a simple BPEL process and try running it in ODE. The process merely performs simple string manipulation. Keep in mind that it is just a simple example, and you can create much more complex processes using the WS-BPEL V2.0 specification. Eclipse BPEL editor To create a simple BPEL process, run Eclipse and click File > New > Other menu item, select the BPEL 2.0 -> BPEL Project option and create a new BPEL project called HelloWorld. Once the project is created, you are ready to create your first BPEL process. Click File > New > Other menu item again and select the BPEL 2.0 > New BPEL Process File option to start with the BPEL process creation wizard, Figure 1. Create a BPEL process file
Let's create a synchronous process also called HelloWorld. On the next page of the wizard, you should choose BPEL process files location — just choose the project created before and click Finish. The sample process will be created. Figure 2. Creating a synchronous process
9 5
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
As shown, the newly created process has two internal BPEL variables — input and output — and a sequence with one receive and one reply element. The receive block is responsible for receiving input BPEL process data and for initialization of the variable input. Similarly, the reply block is aimed at outputting BPEL process data using the output variable. Also during the BPEL process creation, the wizard created a WSDL file. This file describes input and output data types and a port type that represents the BPEL process. Both input and output data types simply contain single string fields. We're ready to add some data manipulation into our process. To do so, drag and drop an Assign block right between the receiveInput and replyOutput blocks. Figure 3. Drag and drop an Assign block
Once the assign block is placed, right-click the Assign block and choose the Show In Properties context menu item to show the Properties view and select the Details tab. The Assign block should initialize the output variable with an initial XML tags structure. It is the common procedure required by most of BPEL processing engines. Click the New button on the Detail tab to start creation of the first assign procedure. Select the Fixed Value element in the From select box and enter following lines into the text area: >tns:HelloWorldResponse xmlns:tns="http://www.ibm.com/wd2/ode/HelloWorld"> >tns:result/> >/tns:HelloWorldResponse> 0 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Next, select the Variable element in the To select box and choose the output/payload variable in the variables tree, as shown below. Figure 4. Initializing output variables
When the output variable is initialized, we can create a new assign procedure. For the sample process, this procedure gets a string value from the input variable, concatenates it with the "Hello" greeting and assigns the result to the output variable string field. For this click the New button and choose the Expression value in the From select box. In the text box displayed below, enter the following expression: concat("Hello ", $input.payload/tns:input). In the To section, select the output/payload/tns:result variable, as shown below. Figure 5. Selecting output/payload/tns:result
The Assign block is ready. As you can see, the Eclipse BPEL plug-in provides XPath V1.0 highlighting and code completion features to simplify creation of XPath queries. (See Resources to learn more about XPath.) WSDL file changes The WSDL file for a BPEL process should describe the types used in the BPEL process as well as port types, bindings, and services for your process. The WSDL automatically created by the wizard already contains a port type and in order to make the process functional, we need to create binding and service for it. Open the WSDL file in the respective editor and see the port type graphical definition. Figure 6. See the port type graphical definition
1 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
To create a Web service binding, right-click any free area in the WSDL editor and choose the Add Binding option. In the Properties view rename the newly created binding to HelloWorldBinding and select HelloWorld as the port type for the new binding. Click the Generate Binding Content button to bring up the Binding Wizard dialog. Figure 7. The Binding Wizard dialog
Select SOAP protocol in the Protocol select box, check the document-literal option in the SOAP Binding Options section and click Finish. Figure 8. Binding options
After the binding is created, right-click a free area of the WSDL editor and choose the Add Service menu item to create a new one with the name HelloWorldService. Then specify HelloWorldPort 2 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
for the binding's port name and the URL http://localhost:8080/ode/processes/HelloWorld for its address. Also select HelloWorldBinding as the binding for the newly created service. Figure 9. HelloWorldBinding
Our WSDL file is ready to be deployed into ODE application. Deployment descriptor The last thing we need to do before our process is ready for deployment is create an ODE descriptor. The descriptor must have the name deploy.xml and must be placed in the same directory where the BPEL and WSDL files are stored. Just create a new deploy.xml text file and put the following content there. Listing 1. Creating a deploy.xml text file
>?xml version="1.0" encoding="UTF-8"?> >deploy xmlns="http://ode.fivesight.com/schemas/2006/06/27/dd" xmlns:pns="http://www.ibm.com/wd2/ode/HelloWorld" xmlns:wns="http://www.ibm.com/wd2/ode/HelloWorld"> >process name="pns:HelloWorld"> >active>true>/active> >provide partnerLink="client"> >service name="wns:HelloWorldService" port="HelloWorldPort"/> >/provide> >/process> >/deploy> The descriptor specifies the list of process and services for a deployable unit. Back to top Usage of BPEL process Now, when the HelloWorld BPEL process is ready, we can deploy it into the ODE application and test it. Deploy BPEL process into ODE ODE supports hot-deployment of BPEL processes. To deploy the process created in previous sections, just copy the folder containing all the process's files into the webapps/ode/WEBINF/processes directory of your Apache Tomcat where ODE was deployed. To monitor deployment process, you can look into the log file logs/catalina.out in the Tomcat root directory for any new entries. An easy way to test the deployed process is to use the Eclipse Web Services Explorer tool. Rightclick your HelloWorld WSDL file and select Web Services > Test with Web Services Explorer pop-up menu item. Eclipse will start the Web Services Explorer test tool. Using this tool, enter some text to the input parameter and invoke the P rocess operation. As shown in Figure 10, the Web service returns the greeting to the text you just entered. Figure 10. Invoke a WSDL operation 3 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Creation of a BPEL process client When we have the Web service that executes the BPEL process, we can integrate this process into a client application. Let's use Eclipse WTP plug-in to generate an Axis-based Web services client. Before generating the client code, you need to add your Tomcat server in the list of Eclipse servers. Click File > New > Other menu item and select the Server option from the list. Then, go through the wizard steps to create a new Tomcat server for your Eclipse workspace. Once the server is created, right-click the WSDL file and select Web Services > Generate Client pop-up menu item. This action starts the Web Service Client wizard, which generates a new project with classes required for work with your Web service. Figure 11. Setting up the Web service client
4 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
To work with the generated files, use the code similar to the following. Listing 2. Creating a Web service client
HelloWorldServiceLocator locator = new HelloWorldServiceLocator(); HelloWorldRequest hwRequest = new HelloWorldRequest(); hwRequest.setInput("developerWorks!"); HelloWorldResponse hwResponse = locator.getHelloWorldPort().process(hwRequest); String output = hwResponse.getResult(); After the code is executed, the output variable should contain the result of the BPEL process work. Back to top ODE Management API ODE provides access through Web services to some of the applications management functionality. By using it, you can control processes deployed in ODE and their instances, which are currently executed on the server. All operations are described in the pmapi.wsdl file located in the folder webapps/ode/WEB-INF of your Tomcat application. Unfortunately, pmapi.wsdl uses the old RPC document style, and it is difficult to use it using the Eclipse Web Services Explorer test tool, for example. 5 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
The best way to access the Management API is to use the Axis2 libraries. In particular, use the ServiceClientUtil class, which is supplied by the ode-axis2 library. Axis2 depends on other libraries, including Xerces, Stax, etc. Most of them are included into the ode.war archive, so you can add it into your project dependencies. The following code demonstrates how to extract information about the current process instances. Listing 3. Extracting information about current process instances
ServiceClientUtil client = new ServiceClientUtil(); OMElement msg = client. buildMessage("listAllInstances", new String[] {}, new String[] {}); OMElement result = client.send(msg, "http://localhost:8080/ode/processes/InstanceManagement"); List>ProcessInfo> processes = new ArrayList>ProcessInfo>(); Iterator>OMElement> i = result.getChildElements(); while (i.hasNext()) { OMElement omInstanceInfo = i.next(); OMElement omProcessName = omInstanceInfo.getFirstChildWithName( new QName("http://www.apache.org/ode/pmapi/types/2006/08/02/", "process-name")); OMElement omStatus = omInstanceInfo.getFirstChildWithName( new QName("http://www.apache.org/ode/pmapi/types/2006/08/02/", "status")); OMElement omStarted = omInstanceInfo.getFirstChildWithName( new QName("http://www.apache.org/ode/pmapi/types/2006/08/02/", "dt-started")); OMElement omLastActive = omInstanceInfo.getFirstChildWithName( new QName("http://www.apache.org/ode/pmapi/types/2006/08/02/", "dt-last-active")); ProcessInfo process = new ProcessInfo(); process.setProcessName(omProcessName.getText()); process.setStatus(omStatus.getText()); process.setStarted(omStarted.getText()); process.setLastActive(omLastActive.getText()); processes.add(process); } The example uses the axiom library to retrieve information and store it as the list of ProcessInfo objects. They can be used from any other part of your application. Back to top ODE event listener ODE allows you to develop listeners for any action inside an ODE application, such as starting and stopping process instances. To create your own event listener, you need to implement the org.apache.ode.bpel.iapi.BpelEventListener interface defined in the ode-bpel-api.jar library. The 6 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
following code demonstrates a simple implementation that prints to the standard output-stream incoming events and invocations of the startup() and shutdown() listener methods. Listing 4. The startup() and shutdown() listener methods
/** * {@inheritDoc} */ public void onEvent(BpelEvent event) { System.out.println(event); } /** * {@inheritDoc} */ public void startup(Properties arg0) { System.out.println(this.getClass() + " startup"); } /** * {@inheritDoc} */ public void shutdown() { System.out.println(this.getClass() + " shutdown"); }
Once a listener class is ready, you need to put it into the ODE classpath (you can put a JAR file with your listener class into the webapps/ode/WEB-INF/lib Tomcat directory). You also need to create the webapps/ode/WEB-INF/conf/ode-axis2.properties property file and add the following line there: ode-axis2.event.listeners=com.ibm.wd2.bpel.eventlistener.WD2EventListener The name of your listener class may differ from the one above.
7 6
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Result Thus WS-BPEL V2.0 business processes using the Eclipse BPEL plug-in plug-in is developed.
Asp.net website using Visual Web Developer 2008. Aim To create an asp.net website using Visual Web Developer 2008. Procedure Step - 1 Download Visual Web Developer from asp.net website (use this url http://asp.net/downloads/essential/) and install it. This is free of cost available and you can use it without any hassle of buying a license.
Step - 2 Open Visual Web Developer from your Start menu by clicking on its "Microsoft Visual Web Developer 2008 Express Edition". It will take few seconds to open. Step - 3 Go to File Menu and Click on New Web Site ... as displayed in the picture below.
8 6
Pre ared ared b : MANIMAR MANIMARAN AN ., Lect/I Lect/IT T
&
RAMACH RAMACHAND ANDRAN RAN.A .A ., Lect/I Lect/IT T
e g a P
Step - 4 A Dialogue box will appear asking for Template, Location, Language. Select/write the location in the location TextBox, Select ASP.NET Web Site as Tempate and Select Visual C# as language as displayed in the picture below. Click OK.
Step - 5 This will create a default.aspx, default.aspx.cs (it is called as codebehind file) file, web.cofig file and an App_Data (It is used to place your database like MS Access or SQL Express or xml files ) folder by default as displayed in the picture below. 9 6
Pre ared ared b : MANIMAR MANIMARAN AN ., Lect/I Lect/IT T
&
RAMACH RAMACHAND ANDRAN RAN.A .A ., Lect/I Lect/IT T
e g a P
Step - 6 Start writing few codes as displayed in the picture below. You can notice that as soon as you started writing code, Visual Web Develope will give intellisense (dropdown) to complete the code of the control as shown in the picture below.
Write a Label control and a Button control as displayed in the picture below. You can notice that in 0 7
Pre ared ared b : MANIMAR MANIMARAN AN ., Lect/I Lect/IT T
&
RAMACH RAMACHAND ANDRAN RAN.A .A ., Lect/I Lect/IT T
e g a P
the OnClick property of the Button control I have specified the name of the method that will fire when the button will be clicked. I will write this method in the Codebehind file.
Step - 7 Now press F7 key from the Keyboard and you will jump to the Codebehind file named default.aspx.cs. Alternatively you can click + symbol beside the default.aspx file and double click default.aspx.cs. Write few lines of code into it as displayed in the picture below. In this file Page_Load method will be automatically written. I am writing SubmitMe method that will fire when Button will be clicked as stated above. Now Save all files by clicking on the Save All toolbar or by going through File->Save All.
Step - 8 Now hit F5 key from your keyboard and your application will start in the debug mode. Alternatively you can click on the Play button from the toolbar. This will ask you to modify the web.cofig file to start the application in the debug mode like picture below. Click OK button. 1 7
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P
Step - 9 After few seconds a browser will open with your default.aspx page like below picture.
Step - 10 Try clicking the Submit button and you will see that a message "Hello World" appears in the browser just beside the Button like below picture.
Output
2 7
Pre ared b : MANIMARAN ., Lect/IT
&
RAMACHANDRAN.A ., Lect/IT
e g a P