Soa lab
Upcoming SlideShare
Loading in...5
×
 

Soa lab

on

  • 587 views

VII sem IT2406

VII sem IT2406

Statistics

Views

Total Views
587
Views on SlideShare
587
Embed Views
0

Actions

Likes
0
Downloads
17
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Soa lab   Soa lab Document Transcript

  • 44210205028 EX No:1(a) BANKING DATE: AIM: To implement banking using .NET component. ALGORITHM: Creating the Component Start Visual Studio .NET and open a new Class Library project – File -> New project. In the New Project dialog box, name the project as ClassLibrary1. Change the name of the class from Class1 to Component name. Enter the Component code into the new class module. Include the following functions:Getpass(), balenquiry(), withdraw(), deposit(). Compile this class as a DLL by clicking Build on the Debug menu.The DLL that results from the build command is placed into the bin directory immediately. To add a Database connection, click on Data -> Add data source and add a new connection. Browse and select the database created in the MS Access. Select the table and test the connection. If successful copy the connection string. Creating the Application Start Visual Studio; clickFile -> New project -> Visual C# -> Windows form application. Set the Name property of the default Windows Form Design the Form by placing controls and naming them. You need to set a reference to the DLL so that this form will be able to consume the components services. Do this by following the steps below. From the class menu click Add Reference. Select the necessary DLL component from the browse menu. Run the application
  • 44210205028 COMPONENT: CLASS1.CS using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Linq; using System.Web; using System.Xml.Linq; namespace ClassLibrary1 { public class Class1 { public int getpass(string n) { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopprobanking.accdb"); con.Open(); string str = "SELECT pass FROM probanking where cust=@var1"; OleDbCommand cmd = new OleDbCommand(str, con); cmd.Parameters.AddWithValue("@var1", n); int ret=(int)cmd.ExecuteScalar(); if (ret != null) { return ret; } else { return 0; } } public int withdrawl(int money, int num) { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopprobanking.accdb"); con.Open(); string str = "SELECT bal FROM probanking where number=@var1"; OleDbCommand cmd = new OleDbCommand(str, con);
  • 44210205028 cmd.Parameters.AddWithValue("@var1", num); int ret = (int)cmd.ExecuteScalar(); int tot = ret - money; con.Close(); OleDbConnection coni = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopprobanking.accdb"); coni.Open(); string str1 = "UPDATE probanking SET bal="+tot+" "+" WHERE number="+num; OleDbCommand cmd1 = new OleDbCommand(str1, coni); cmd1.ExecuteNonQuery(); // cmd.Parameters.AddWithValue("@var2", tot); coni.Close(); return tot; } public int balenquriy(int acc) { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopprobanking.accdb"); con.Open(); string str = "SELECT bal FROM probanking where number="+acc; OleDbCommand cmd = new OleDbCommand(str, con); cmd.Parameters.AddWithValue("@var1", acc); int ret = (int)cmd.ExecuteScalar(); return ret; } public int deposit(int money, int num) { OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopprobanking.accdb"); con.Open(); string str = "SELECT bal FROM probanking where number=@var1"; OleDbCommand cmd = new OleDbCommand(str, con); cmd.Parameters.AddWithValue("@var1", num); int ret = (int)cmd.ExecuteScalar(); int tot = ret + money;
  • 44210205028 string str1 = "UPDATE probanking SET bal="+tot+" "+"WHERE number="+num; OleDbCommand cmd1 = new OleDbCommand(str1, con); int r=(int) cmd1.ExecuteNonQuery(); return tot; } } } APPLICATION CODE: FORM1.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ClassLibrary1; namespace probanking { public partial class Form1 : Form { Class1 obj = new Class1(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string name = textBox1.Text; string pass = textBox2.Text; int rer = int.Parse(pass); int ret = obj.getpass(name); if (ret==rer) {
  • 44210205028 Form2 f2 = new Form2(); f2.Show(); this.Hide(); } else { MessageBox.Show("invalid password"); } } private void button2_Click(object sender, EventArgs e) { this.Close(); } } } FORM2.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ClassLibrary1; namespace probanking { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form3 f3 = new Form3(); f3.Show();
  • 44210205028 this.Hide(); } private void button2_Click(object sender, EventArgs e) { Form4 f4 = new Form4(); f4.Show(); this.Hide(); } private void button3_Click(object sender, EventArgs e) { Form5 f5 = new Form5(); f5.Show(); this.Hide(); } private void button4_Click(object sender, EventArgs e) { this.Close(); } } } FORM3.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ClassLibrary1; namespace probanking { public partial class Form3 : Form { Class1 obj = new Class1(); public Form3() { InitializeComponent(); }
  • 44210205028 private void label1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { string num = textBox1.Text; string acc = textBox2.Text; int account = int.Parse(acc); int number = int.Parse(num); int retur = obj.withdrawl(account, number); MessageBox.Show("Your Balance is " + retur); } private void textBox2_TextChanged(object sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button3_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); this.Hide(); } } } FORM4.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq;
  • 44210205028 using System.Text; using System.Windows.Forms; using ClassLibrary1; namespace probanking { public partial class Form4 : Form { Class1 obj = new Class1(); public Form4() { InitializeComponent(); } private void label3_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { string num = textBox1.Text; string acc = textBox2.Text; int account = int.Parse(acc); int number = int.Parse(num); int retur = obj.deposit(account, number); MessageBox.Show("Current Balance is " + retur); } private void button3_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); this.Hide(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } } }
  • 44210205028 FORM5.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ClassLibrary1; namespace probanking { public partial class Form5 : Form { Class1 obj = new Class1(); public Form5() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string acc = textBox1.Text; int acc1 = int.Parse(acc); int ret=obj.balenquriy(acc1); textBox2.Text = Convert.ToString(ret); } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button3_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); this.Hide(); } } }
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028 EX No:1(b) ONLINE COURSE REGISTRATION DATE: AIM: To implement course registration using .NET component. ALGORITHM: Creating the Component Start Visual Studio .NET and open a new Class Library project, File -> New project. In the New Project dialog box, name the project classLibrary4. Change the name of the class from Class1 to Component name. Enter the Component code into the new class module. Include the following functions: func(), ret(). Compile this class as a DLL by clicking Build on the Debug menu.The DLL that results from the build command is placed into the bin directory immediately. To add a Database connection, click on Data -> Add data source and add a new connection. Browse and select the database created in the MS Access. Select the table and test the connection. If successful copy the connection string. Creating the Application Start Visual Studio Start Visual Studio; clickFile -> New project -> Visual C# -> Windows form application. Set the Name property of the default Windows Form Design the Form by placing controls and naming them. You need to set a reference to the DLL so that this form will be able to consume the components services. Do this by following the steps below. From the class menu click Add Reference. Select the necessary DLL component from the browse menu. Run the application
  • 44210205028 COMPONENT CODE: CLASS1.CS using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.OleDb; namespace ClassLibrary4 { public class Class1 { OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopresult.accdb"); DataTable dt = new DataTable(); public int func(int a, int b) { if (a >= 75 && b >= 18) return 1; else return 0; } public DataTable ret(String query) { try { conn.Open(); OleDbCommand cmd = new OleDbCommand(query,conn); OleDbDataAdapter adp = new OleDbDataAdapter(cmd); dt.Clear(); adp.Fill(dt); } catch { } finally { conn.Close(); } return dt; } } }
  • 44210205028 APPLICATION CODE: FORM1.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace olc { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); this.Hide(); } } } FORM2.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace olc {
  • 44210205028 public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form3 f3 = new Form3(); f3.Show(); this.Hide(); } private void button2_Click(object sender, EventArgs e) { Form4 f4 = new Form4(); f4.Show(); this.Hide(); } } } FORM3.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace olc { public partial class Form3 : Form { public Form3() { InitializeComponent(); } private void Form3_Load(object sender, EventArgs e) {
  • 44210205028 // TODO: This line of code loads data into the 'studentDataSet.UG' table. You can move, or remove it, as needed. this.uGTableAdapter.Fill(this.studentDataSet.UG); } private void button1_Click(object sender, EventArgs e) { Form5 f5 = new Form5(); f5.Show(); this.Hide(); } } } FORM4.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace olc { public partial class Form4 : Form { public Form4() { InitializeComponent(); } private void Form4_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'studentDataSet1.PG' table. You can move, or remove it, as needed. this.pGTableAdapter.Fill(this.studentDataSet1.PG); } private void button1_Click(object sender, EventArgs e) { Form5 f5 = new Form5();
  • 44210205028 f5.Show(); this.Hide(); } } } FORM5.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using ClassLibrary4; namespace olc { public partial class Form5 : Form { public Form5() { InitializeComponent(); } private void label2_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { Class1 c1 = new Class1(); Form5 f5 = new Form5(); Form6 f6 = new Form6(); String marks = textBox5.Text; String age = textBox6.Text; String id = textBox2.Text; String name= textBox3.Text; String email= textBox4.Text; int m = int.Parse(marks); int a = int.Parse(age);
  • 44210205028 int z = c1.func(m, a); if (z == 1) { this.Hide(); OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopresult.accdb"); conn.Open(); string strquery = "INSERT INTO res VALUES ('" + id + "', '" + name + "', '" + email + "','"+marks +"','"+age+"');"; OleDbCommand cmd = new OleDbCommand(strquery, conn); cmd.ExecuteNonQuery(); f6.Show(); this.Hide(); } else { MessageBox.Show("Not eligible"); } } } } FORM6.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace olc { public partial class Form6 : Form { public Form6() { InitializeComponent();
  • 44210205028 } private void button1_Click(object sender, EventArgs e) { Form7 f7 = new Form7(); f7.Show(); this.Hide(); } } } FORM7.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using System.Data; using ClassLibrary4; namespace olc { public partial class Form7 : Form { Class1 obj = new Class1(); public Form7() { InitializeComponent(); } private void Form7_Load(object sender, EventArgs e) { dataGridView1.DataSource = obj.ret("SELECT * FROM res"); } } }
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028 EX No:1(c) ORDER PROCESSING DATE: AIM: To implement order processing using .NET component. ALGORITHM: Creating the Component Start Visual Studio .NET and open a new Class Library project, File -> New project. In the New Project dialog box, name the project ClassLibrary2. Change the name of the class from Class1 to Component name. Enter the Component code into the new class module. Include the following functions: ret(), pay(), insertin(), change(). Compile this class as a DLL by clicking Build on the Debug menu.The DLL that results from the build command is placed into the bin directory immediately. To add a Database connection, click on Data -> Add data source and add a new connection. Browse and select the database created in the MS Access. Select the table and test the connection. If successful copy the connection string. Creating the Application Start Visual Studio; clickFile -> New project -> Visual C# -> Windows form application. Set the Name property of the default Windows Form Design the Form by placing controls and naming them. You need to set a reference to the DLL so that this form will be able to consume the components services. Do this by following the steps below. From the class menu click Add Reference. Select the necessary DLL component from the browse menu. Run the application
  • 44210205028 COMPONENT CODE: CLASS1.CS using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Linq; using System.Web; using System.Xml.Linq; namespace ClassLibrary2 { public class Class1 { static int isbn; public void search(int num) { isbn = num; } public int ret() { int sa = isbn; return sa; } public int pay(int isb, int bo) { OleDbConnection conz = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopFinalproprocess.accdb"); conz.Open(); string an = "SELECT quantity FROM proprocess where isbn=@var2"; OleDbCommand cmd1 = new OleDbCommand(an, conz); cmd1.Parameters.AddWithValue("@var2", isb); int are = (int)cmd1.ExecuteScalar(); if (are < bo) { return 0; } else {
  • 44210205028 string ant = "SELECT cost FROM proprocess where isbn=@var2"; OleDbCommand cmd2 = new OleDbCommand(ant, conz); cmd2.Parameters.AddWithValue("@var2", isb); int arec = (int)cmd2.ExecuteScalar(); return arec; } } public void insertin(string cnam, int number, int amount) { OleDbConnection conz = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopFinalproprocess.accdb"); conz.Open(); string an = "INSERT INTO proinvoice VALUES ('" + cnam + "', " + amount + ", " + number + ")"; OleDbCommand cmd1 = new OleDbCommand(an, conz); cmd1.ExecuteNonQuery(); } public void change(int num) { int isb = isbn; OleDbConnection conz = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopFinalproprocess.accdb"); conz.Open(); string an = "SELECT quantity FROM proprocess where isbn=@var2"; OleDbCommand cmd1 = new OleDbCommand(an, conz); cmd1.Parameters.AddWithValue("@var2", isb); int are = (int)cmd1.ExecuteScalar(); int tot = are - num; string str = "UPDATE proprocess SET quantity=" + tot + " " + "WHERE isbn=" + isb; OleDbCommand cmd = new OleDbCommand(str, conz); cmd.ExecuteNonQuery(); } } }
  • 44210205028 APPLICATION CODE: FORM1.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace proprocess { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); this.Hide(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } } } FORM2.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
  • 44210205028 using System.Windows.Forms; using ClassLibrary2; namespace proprocess { public partial class Form2 : Form { Class1 obj = new Class1(); public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string num = textBox1.Text; int num1 = int.Parse(num); obj.search(num1); Form3 f3 = new Form3(); f3.Show(); this.Hide(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } } } FORM3.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; using ClassLibrary2;
  • 44210205028 namespace proprocess { public partial class Form3 : Form { Class1 obj = new Class1(); public Form3() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button1_Click(object sender, EventArgs e) { } private void button1_Click_1(object sender, EventArgs e) { Form4 f4 = new Form4(); f4.Show(); this.Hide(); } private void Form3_Load(object sender, EventArgs e) { int num1 = obj.ret(); OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsstudentDesktopFinalproprocess.accdb"); con.Open(); string str = "SELECT * FROM proprocess where isbn=@var1"; OleDbCommand cmd = new OleDbCommand(str, con); cmd.Parameters.AddWithValue("@var1", num1); OleDbDataReader re; re = cmd.ExecuteReader();
  • 44210205028 if (re.Read()) { textBox1.Text = (re[0].ToString()); textBox2.Text = (re[2].ToString()); textBox3.Text = (re[1].ToString()); textBox4.Text = (re[4].ToString()); textBox5.Text = (re[3].ToString()); } else { MessageBox.Show("Failed"); } } } } FORM4.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ClassLibrary2; namespace proprocess { public partial class Form4 : Form { Class1 obj = new Class1(); public Form4() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string unit = textBox2.Text; int unitn = int.Parse(unit); int isbn = obj.ret(); int retm=obj.pay(isbn, unitn);
  • 44210205028 if (retm == 0) { MessageBox.Show("Units not available"); } else { int tot = retm * unitn; string temp = Convert.ToString(tot); textBox3.Text = temp; } } private void button3_Click(object sender, EventArgs e) { string nu = textBox2.Text; int number = int.Parse(nu); obj.change(number); Form5 f5 = new Form5(); f5.Show(); this.Hide(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void textBox2_TextChanged(object sender, EventArgs e) { } } } FORM5.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ClassLibrary2;
  • 44210205028 namespace proprocess { public partial class Form5 : Form { Class1 obj = new Class1(); public Form5() { InitializeComponent(); } private void label1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { string cname = textBox1.Text; int num = int.Parse(textBox2.Text); int amt = int.Parse(textBox3.Text); obj.insertin(cname, num, amt); Form6 f6 = new Form6(); f6.Show(); this.Hide(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } } }
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028 EX No:1(e) CALCULATOR DATE: AIM: To implement calculator using .NET component. ALGORITHM: Creating the Component Start Visual Studio .NET and open a new Class Library project, File -> New project. In the New Project dialog box, name the project calclogic. Change the name of the class from Class1 to Component name. Enter the Component code into the new class module. Include the following functions: add(). Sub(), mul(), div(), sin(), cos(), tan(), dot(), sqrt(), square(), cube(), log(). Compile this class as a DLL by clicking Build on the Debug menu.The DLL that results from the build command is placed into the bin directory immediately. To add a Database connection, click on Data -> Add data source and add a new connection. Browse and select the database created in the MS Access. Select the table and test the connection. If successful copy the connection string. Creating the Application Start Visual Studio; clickFile -> New project -> Visual C# -> Windows form application. Set the Name property of the default Windows Form Design the Form by placing controls and naming them. You need to set a reference to the DLL so that this form will be able to consume the components services. Do this by following the steps below. From the class menu click Add Reference. Select the necessary DLL component from the browse menu. Run the application
  • 44210205028 COMPONENT: CLASS1.CS using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.OleDb; using System.Linq; using System.Web; using System.Xml.Linq; namespace calclogic { public class Class1 { public float add(float a, float b) { return a + b; } public float sub(float a, float b) { return a - b; } public float mul(float a, float b) { return a * b; } public float div(float a, float b) { return a/b; } public double log(double a) { return Math.Log(a); } public double tan(double a) { return Math.Tan(a); } public double cos(double a) { return Math.Cos(a); } public double sin(double a) {
  • 44210205028 return Math.Sin(a); } public string dot() { return "."; } public double sqrt(double a) { return Math.Sqrt(a); } public double square(double a) { return Math.Pow(a, 2); } public double cube(double a) { return Math.Pow(a, 3); } } } FORM1.CS using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using calclogic; namespace WindowsFormsApplication5 { public partial class Form1 : Form { Class1 obj = new Class1(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { float a = float.Parse(textBox1.Text);
  • 44210205028 float b = float.Parse(textBox2.Text); float c = obj.add(a, b); textBox3.Text = c.ToString(); } private void button2_Click(object sender, EventArgs e) { float a = float.Parse(textBox1.Text); float b = float.Parse(textBox2.Text); float c = obj.sub(a, b); textBox3.Text = c.ToString(); } private void button3_Click(object sender, EventArgs e) { float a = float.Parse(textBox1.Text); float b = float.Parse(textBox2.Text); float c = obj.mul(a, b); textBox3.Text = c.ToString(); } private void button4_Click(object sender, EventArgs e) { float a = float.Parse(textBox1.Text); float b = float.Parse(textBox2.Text); float c = obj.div(a, b); textBox3.Text = c.ToString(); } private void button5_Click(object sender, EventArgs e) { double a = double.Parse(textBox1.Text); double c = obj.log(a); textBox3.Text = c.ToString(); } private void button6_Click(object sender, EventArgs e) { double a = double.Parse(textBox1.Text); double c = obj.sin(a); textBox3.Text = c.ToString(); } private void button7_Click(object sender, EventArgs e) { double a = double.Parse(textBox1.Text);
  • 44210205028 double c = obj.cos(a); textBox3.Text = c.ToString(); } private void button8_Click(object sender, EventArgs e) { double a = double.Parse(textBox1.Text); double c = obj.tan(a); textBox3.Text = c.ToString(); } private void button11_Click(object sender, EventArgs e) { double a = double.Parse(textBox1.Text); double c = obj.sqrt(a); textBox3.Text = c.ToString(); } private void button12_Click(object sender, EventArgs e) { double a = double.Parse(textBox1.Text); double c = obj.square(a); textBox3.Text = c.ToString(); } private void button9_Click(object sender, EventArgs e) { double a = double.Parse(textBox1.Text); double c = obj.cube(a); textBox3.Text = c.ToString(); } } }
  • 44210205028
  • 44210205028 EX No: 2 INVOKE .NET COMPONENT AS A WEB SERVICE DATE: AIM: To invoke a .NET component as a web service. ALGORITHM: Create a class library. Add the appropriate sample codes to the class. Modify the properties of the class library, Right click -> class library name -> properties Assembly information. Make Assembly COM visible.Build -> Register for COM interop Build the project and the dll will be created. Create a new asmx project. Right click on the project and click add reference. Then browse the appropriate dll and click ok. Add the code in the asmx file. Create a new website type ASP.NET in c# code and do the appropriate form designing. Add the corresponding web reference Right click -> Add Web Reference. Copy and paste the WSDL link generated from the Web Service project. Insert the code on the button click operation. Build the website and click on Debug tab and start without Debugging. Now the project will invoke the web service and in turn invoke the dll.
  • 44210205028 CLASS LIBRARY: Class1.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ClassLibrary1 { public class Class1 { public double celtofar(double c) { double a; a = (1.8 * c) + 32; return a; } public double fartocel(double f) { double a; a = 0.55 * (f - 32); return a; } } } Service1.asmx.cs using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; namespace WebService1 { /// <summary> /// Summary description for Service1 /// </summary> [WebService(Namespace = "http://tempuri.org/")]
  • 44210205028 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod] public double ctof(double c) { ClassLibrary1.Class1 obj = new ClassLibrary1.Class1(); return obj.celtofar(c); } [WebMethod] public double ftoc(double f) { ClassLibrary1.Class1 obj = new ClassLibrary1.Class1(); return obj.fartocel(f); } } } WEB APPLICATION : using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { }
  • 44210205028 protected void Button1_Click1(object sender, EventArgs e) { double a, b; a = Double.Parse(TextBox1.Text); localhost.Service1 ws = new localhost.Service1(); b = ws.ctof(a); TextBox2.Text = b.ToString(); } protected void Button2_Click1(object sender, EventArgs e) { double a, b; a = Double.Parse(TextBox3.Text); localhost.Service1 ws = new localhost.Service1(); b = ws.ftoc(a); TextBox4.Text = b.ToString(); } } }
  • 44210205028 RESULT:
  • 44210205028 EX No: 3(a) DEVELOP COMPONENTS USING EJB COMPONENT TECHNOLOGY DATE: ORDER PROCESSING AIM: To develop an Order Processing component using EJB component as a web service. ALGORITHM: Step 1: Go to NetBeans IDE-> File -> New Project -> Java EE -> EJB Module -> Next and name the project as “orderprocessing” -> Next -> Finish. Step 2: Create new web service a. Right Click the created project name -> New -> Web Service -> Give name for the web service and package -> Finish. b. A new folder named “web services” will be created under the project folder. Inside that, new web services will be created. Step 3: Creating function for web service Under the web services folder, right click the web service created -> Add operation. *Give the appropriate name for the operation *Select the return type of the function *Adding parameters: Click Add -> Give name of the parameter and their data type. Click OK. Step 4: Write the required operation inside the function and also see to the return type matches. Write the required coding and save the file. ______________________________________________________________________________ /* Sample Code */ @WebMethod(operationName=”subtotal”) Public double subtotal(@WebParam(name= “id”) int id, @WebParam(name= “quant”) int quantity) ______________________________________________________________________________ Step 5: Right Click on the webservice -> Add Operation -> choose the operation name and return type. Step 6: a. Right Click the project -> Deploy
  • 44210205028 b.In the web service folder, right click on the web service -> Test web service. Step 7: Get into NetBeans IDE, go to File -> New Project -> Java -> Web Application Give the name of the project as “clientpro”. Step 8: Create a Home Page to receive sequence. Step 9: Create component necessary to invoke the service from the client a.Right click “clientpro” -> new -> WebServiceClient b. Click Browse and select the required service. Step 10: Build and Run the Web Application. PROGRAM: ORDERSERVER.JAVA package pack; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.ejb.Stateless; import java.sql.*; @WebService(serviceName = "orderserver") @Stateless() public class orderserver { /** This is a sample web service operation */ @WebMethod(operationName = "hello") public String hello(@WebParam(name = "name") String txt) { return "Hello " + txt + " !"; } @WebMethod(operationName = "subTotal") public double subTotal(@WebParam(name = "id") int id, @WebParam(name = "quantity") int quantity) { double price,total=0; try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection con= DriverManager.getConnection("jdbc:derby://localhost:1527/orderdb","student","student"); Statement stmt=con.createStatement(); ResultSet rs= stmt.executeQuery("select * from APP.LIST where id="+id); while(rs.next())
  • 44210205028 { price=rs.getDouble("price"); total=price*quantity; } } catch(Exception e) {} return total; } } INDEX.JSP <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> <style type="text/css"> #border{ border:white solid 2px; margin-top: 10%; font-family: bliss; font-size: 20px; } </style> </head> <body id="border"> <center><h1> shopping world </h1> <h1> welcome </h1> </center> <form action="http://localhost:8080/orderclient/display.jsp" method="get"><div align="center"> GET details by clicking this button <input type="submit" valur="GetDetails" style="font-family: bliss; font-size: 20px;"/> </div></form> </body> </html> DISPLAY.JSP
  • 44210205028 <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.util.*;" %> <%@page import="java.sql.*;" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> <style type="text/css"> #border { border:white solid 2px; margin-top: 10%; font-family: bliss; font-size: 20px; } input{ font-family: bliss; font-size: 20px; } </style> </head> <body id="border"> <h1 align="center"> welcome </h1> <form action="http://localhost:8080/orderclient/calc.jsp" method="get"> <table border="2px;" align="center"> <tr> <th> product-ID</th> <th> product_Name</th> <th> product_price</th> <th> Quantity</th> </tr> <% try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection con= DriverManager.getConnection("jdbc:derby://localhost:1527/orderdb","student","student"); Statement stmt=con.createStatement(); ResultSet rs= stmt.executeQuery("select * from APP.LIST");
  • 44210205028 while(rs.next()) { %> <tr> <td><%=rs.getInt("id")%></td> <td><%=rs.getString("name")%></td> <td><%=rs.getDouble("price")%></td> <td><input type="text" value="0" name="<%=rs.getInt("id")%>"/></td> </tr> <%} } catch(Exception e) { }%> </table><br> <input type="submit" value="Purchase" style="margin-left: 45%;margin-top: 10px;padding: 10px;font-family: bliss;font-size: 20px;"/> </form> </body> </html> CALC.JSP <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.util.*;"%> <%@page import="java.sql.*;"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> <style type="text/css"> #border { border:white solid 2px; margin-top: 10%; font-family: bliss; font-size: 20px; } input{ font-family: bliss;
  • 44210205028 font-size: 20px; } </style> </head> <body id="border"> <h1 align="center"> Online billing for ur product </h1> <table border="2px;" align="center"> <tr> <th> product-ID</th> <th> product_Name</th> <th> product_price</th> <th> Quantity</th> </tr> <% double total=0,amt=0; try { pack.Orderserver_Service service=new pack.Orderserver_Service(); pack.Orderserver port=service.getOrderserverPort(); int quantity; Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection con= DriverManager.getConnection("jdbc:derby://localhost:1527/orderdb","student","student"); Statement stmt=con.createStatement(); ResultSet rs= stmt.executeQuery("select * from APP.LIST"); while(rs.next()) { String idq=rs.getString("id"); int id=rs.getInt("id"); quantity=Integer.parseInt(request.getParameter(idq)); amt=port.subTotal(id,quantity); total+=amt; %> <tr> <td><%=id%></td> <td><%=rs.getString("name")%></td> <td><%=rs.getDouble("price")%></td> <td><%=quantity%></td> <td><%=amt%></td> </tr>
  • 44210205028 <%} } catch(Exception e) {} %> <tr> <td colspan="4"><b> Total </b></td> <td><b><%=total%></b></td> </tr> </table> <br><center> <form action="thanks.jsp" method="get" name="form1"> <input type="submit" value="ok"/> </form> </center> </body> </html> THANKS.Jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> <style type="text/css"> #border { border:white solid 2px; margin-top: 10%; margin-left: 15%; } </style> </head> <body id="border"> <h1 style="font-family: bliss"> thank you</h1> </body> </html>
  • 44210205028 OUTPUT:
  • 44210205028 RESULT: Thus the Order Processing component has been created using EJB component as web service.
  • 44210205028 EX No: 3(b) PAYMENT PROCESSING DATE: AIM: To develop a Payment Processing component using EJB component as a web service. ALGORITHM: Step 1: Go to NetBeans IDE-> File -> New Project -> Java EE -> EJB Module -> Next and name the project as “paymentprocessing” -> Next -> Finish. Step 2: Create new web service a. Right Click the created project name -> New -> Web Service -> Give name for the web service and package -> Finish. b. A new folder named “web services” will be created under the project folder. Inside that, new web services will be created. Step 3: Creating function for web service Under the web services folder, right click the web service created -> Add operation. *Give the appropriate name for the operation *Select the return type of the function *Adding parameters: Click Add -> Give name of the parameter and their data type. Click OK. Step 4: Write the required operation inside the function and also see to the return type matches. Write the required coding and save the file. /* Sample Code */
  • 44210205028 __________________________________________________________________________ @WebMethod(operationName=”getBalance”) Public int getBalance(@WebParam(name= “ino”) int ino) __________________________________________________________________________ Step 5: Right Click on the webservice -> Add Operation -> choose the operation name and return type. Step 6: a. Right Click the project -> Deploy c. In the web service folder, right click on the web service -> Test web service. Step 7: Get into NetBeans IDE, go to File -> New Project -> Java -> Web Application Give the name of the project as “clientpayment”. Step 8: Create a Home Page to receive sequence. Step 9: Create component necessary to invoke the service from the client a. Right click “clientpayment” -> new -> WebServiceClient b. Click Browse and select the required service. Step 10: Build and Run the Web Application. PROGRAM: PaymentServer: package pack; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.*;
  • 44210205028 import javax.ejb.Stateless; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; @WebService(serviceName="payws") @Stateless() public class payws { int bal,i; Date d=new Date(); String a=""; @WebMethod(operationName="getCDate") public Date getCDate(@WebParam(name="ino")int ino) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/paydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.PAYM where INVOICE_NO="+ino); while(rs.next()) { d=rs.getDate("CREATED_ON"); } } catch(Exception e) {
  • 44210205028 } return d; } @WebMethod(operationName="getFDate") public Date getFDate(@WebParam(name="ino")int ino) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/paydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.PAYM where INVOICE_NO="+ino); while(rs.next()) { d=rs.getDate("COMPLETED_ON"); } } catch(Exception e) { } return d; } @WebMethod(operationName="getBalance") public int getBalance(@WebParam(name="ino")int ino) { try {
  • 44210205028 Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/paydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.PAYM where INVOICE_NO="+ino); while(rs.next()) { bal=rs.getInt("BAL_DUE"); } } catch(Exception e) { } return bal; } @WebMethod(operationName="getAmtPaid") public int getAmtPaid(@WebParam(name="ino")int ino) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/paydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.PAYM where INVOICE_NO="+ino); while(rs.next()) { bal=rs.getInt("AMT_PAID");
  • 44210205028 } } catch(Exception e) { } return bal; } @WebMethod(operationName="update") public int update(@WebParam(name="ino")int ino,@WebParam(name="amt")int amt) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/paydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.PAYM where INVOICE_NO="+ino); while(rs.next()) { bal=rs.getInt("BAL_DUE"); i=rs.getInt("AMT_PAID"); } if(bal==0) { return 0; } bal=bal-amt; i=i+amt;
  • 44210205028 if(bal==0) { stmt.executeUpdate("update APP.PAYM set COMPLETED_ON=CURRENT-DATE where INVOICE_NO="+ino); } stmt.executeUpdate("update APP.PAYM set AMT_PAID="+i+" where INVOICE_NO="+ino); stmt.executeUpdate("update APP.PAYM set BAL_DUE="+bal+" where INVOICE_NO="+ino); stmt.close(); } catch(Exception e) { } return 1; } } PaymentClient: First.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="javax.xml.datatype.*"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; Charset=UTF-8"> <title>payment processing</title> </head> <body> <h1>Make Payment</h1> <hr/>
  • 44210205028 <% try { pack.Payws_Service s=new pack.Payws_Service(); pack.Payws port=s.getPaywsPort(); %> <form action=third.jsp> ENTER THE AMOUNT YOU WISH TO PAY <input type=text name=amount> <input type=submit value=SUBMIT> <table border=2 align=center> <tr> <th> INVOICE NUMBER </th> <th> CREATED_ON </th> <th> BALANCE_DUE </th> <th> AMOUNT_PAID </th> <th> COMPLETED_ON </th>
  • 44210205028 </tr> <% int ino=Integer.parseInt(request.getParameter("ino")); out.print("<input type=hidden name=ino value="+ino+">"); int bal=port.getBalance(ino); int amt=port.getAmtPaid(ino); XMLGregorianCalendar c=port.getCDate(ino); XMLGregorianCalendar f=port.getFDate(ino); %> <td><%=ino%></td> <td><%=c.toString()%></td> <td><%=bal%></td> <td><%=amt%></td> <td><%=f.toString()%></td> </tr></table><br> </form> <% } catch(Exception ex) { } %> <hr/> </body> </html> Index.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%>
  • 44210205028 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Payment Processing</title> </head> <body> <center> <h1>PAYMENT PROCESSING</h1></center> <hr/> <% try { pack.Payws_Service s=new pack.Payws_Service(); pack.Payws port= s.getPaywsPort(); %> <center> <form action=first.jsp> <h3>Enter the invoice number</h3> <input type=text name=ino> To make Payment Click here <input type=submit value=Click> </form> <form action=second.jsp> <h3>Enter the invoice number</h3> <input type=text name=ino> To view the status invoice
  • 44210205028 <input type=submit value=click> </form> </center> <% } catch(Exception ex) { } %> </body> </html> Second.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="javax.xml.datatype.*"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>payment processing</title> </head> <body> <h1>Invoice Details</h1> <hr/> <% try { pack.Payws_Service s=new pack.Payws_Service();
  • 44210205028 pack.Payws port=s.getPaywsPort(); %> <form> <table border=2 align=center> <tr><th>INVOICE_NO</th> <th>CREATED_ON</th> <th>BALANCE_DUE</th> <th>AMOUNT_PAID</th> <th>COMPLETED_ON</th> </tr> <% int ino=Integer.parseInt(request.getParameter("ino")); out.print("<input type=hidden name=ino value="+ino+">"); int bal=port.getBalance(ino); int amt=port.getAmtPaid(ino); XMLGregorianCalendar c=port.getCDate(ino); XMLGregorianCalendar f=port.getFDate(ino); %> <tr> <td><%=ino%></td> <td><%=c.toString()%></td> <td><%=bal%></td> <td><%=amt%></td> <td><%=f.toString()%></td> </tr></table><br> </form> <%
  • 44210205028 } catch(Exception ex) { } %> </body> </html> Third.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="javax.xml.datatype.*"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>payment processing</title> </head> <body> <h1>thank you</h1> <% try { pack.Payws_Service service=new pack.Payws_Service(); pack.Payws port=service.getPaywsPort(); int ino=Integer.parseInt(request.getParameter("ino")); int amount=Integer.parseInt(request.getParameter("amount")); int i=port.update(ino,amount); if(i==0)
  • 44210205028 { out.print("head"); out.print("<body><h3>your balance is alreadu 0</h3></body></html>"); } else { %> <form> <table border=2 align=center> <tr><th>INVOICE_NO</th> <th>CREATED_ON</th> <th>BALANCE_DUE</th> <th>AMOUNT_PAID</th> <th>COMPLETED_ON</th> </tr> <% int bal=port.getBalance(ino); int amt=port.getAmtPaid(ino); XMLGregorianCalendar c=port.getCDate(ino); XMLGregorianCalendar f=port.getFDate(ino); %> <tr> <td><%=ino%></td> <td><%=c.toString()%> <td><%=bal%></td> <td><%=amt%></td>
  • 44210205028 <td><%=f.toString()%></td> </tr></table><br> </form> <% } } catch(Exception e) { } %> </body> </html> OUTPUT:
  • 44210205028
  • 44210205028 RESULT: Thus the Payment Processing component has been created using EJB component as web service.
  • 44210205028 EX No: 3(c) CALCULATOR DATE: AIM: To develop Calculator component using EJB component as a web service. ALGORITHM: Step 1: Go to NetBeans IDE-> File -> New Project -> Java EE -> EJB Module -> Next and name the projectas “Calculator” -> Next -> Finish. Step 2: Create new web service d. Right Click the created project name -> New -> Web Service -> Give name for the web service and package -> Finish. e. A new folder named “web services” will be created under the project folder. Inside that, new web services will be created. Step 3: Creating function for web service Under the web services folder, right click the web service created -> Add operation. *Give the appropriate name for the operation *Select the return type of the function *Adding parameters: Click Add -> Give name of the parameter and their data type. Click OK. Step 4: Write the required operation inside the function and also see to the return type matches. Write the required coding and save the file. * Sample Code
  • 44210205028 ________________________________________________________________________ @WebMethod(operationName=”getBalance”) Public int getBalance(@WebParam(name= “ino”) int ino) __________________________________________________________________________ Step 5: Right Click on the webservice -> Add Operation -> choose the operation name and return type. Step 6: a. Right Click the project -> Deploy f. In the web service folder, right click on the web service -> Test web service. Step 7: Get into NetBeans IDE, go to File -> New Project -> Java -> Web Application Give the name of the project as “clientcalc”. Step 8: Create a Home Page to receive sequence. Step 9: Create component necessary to invoke the service from the client c. Right click “clientcalc” -> new -> WebServiceClient d. Click Browse and select the required service. Step 10: Build and Run the Web Application. PROGRAM: Calcservice.java package calpack; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.ejb.Stateless; /** * * @author student
  • 44210205028 */ @WebService(serviceName = "Calcservice") @Stateless() public class Calcservice { /** This is a sample web service operation */ /** * Web service operation */ @WebMethod(operationName = "add") public int add(@WebParam(name = "a") int a, @WebParam(name = "b") int b) { //TODO write your implementation code here: return a+b; } /** * Web service operation */ @WebMethod(operationName = "sub") public int sub(@WebParam(name = "a") int a, @WebParam(name = "b") int b) { //TODO write your implementation code here: return a-b; } /** * Web service operation */ @WebMethod(operationName = "mult") public int mult(@WebParam(name = "a") int a, @WebParam(name = "b") int b) {
  • 44210205028 //TODO write your implementation code here: return a*b; } /** * Web service operation */ @WebMethod(operationName = "divide") public double divide(@WebParam(name = "a") double a, @WebParam(name = "b") double b) { //TODO write your implementation code here: return a/b; } } INDEX.JSP <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1> Calculator </h1> <% try {
  • 44210205028 calpack.Calcservice_Service service=new calpack.Calcservice_Service(); calpack.Calcservice port=service.getCalcservicePort(); int a=0; int b=0; int result1=port.add(5, 6); int result2=port.mult(5, 6); int result3=port.sub(6, 5); double result4=port.divide(85.5, 5.5); out.println("<b>Sum</b> ="+result1); out.println("<br><b>Difference</b>="+result3); out.println("<br><b>Product</b> ="+result2); out.println("<br><b>Quotient</b> ="+result4); } catch(Exception e) { } %> </body> </html>
  • 44210205028 OUTPUT:
  • 44210205028
  • 44210205028 RESULT: Thus the Calculator component has been created using EJB component as web service.
  • 44210205028 EX No: 3(d) STUDENT MARKLIST DATE: AIM: To develop student marklistcomponent using EJB component as a web service. ALGORITHM: Step 1: Go to NetBeans IDE-> File -> New Project -> Java EE -> EJB Module -> Next and name the project as “marklistprocessing” -> Next -> Finish. Step 2: Create new web service g. Right Click the created project name -> New -> Web Service -> Give name for the web service and package -> Finish. h. A new folder named “web services” will be created under the project folder. Inside that, new web services will be created. Step 3: Creating function for web service Under the web services folder, right click the web service created -> Add operation. *Give the appropriate name for the operation *Select the return type of the function *Adding parameters: Click Add -> Give name of the parameter and their data type. Click OK. Step 4: Write the required operation inside the function and also see to the return type matches. Write the required coding and save the file. _______________________________________________________________________ /* Sample Code */ @WebMethod(operationName=”getName”) Public String getName(@WebParam(name= “no”) int no) ________________________________________________________________________
  • 44210205028 Step 5: Right Click on the webservice -> Add Operation -> choose the operation name and return type. Step 6: a. Right Click the project -> Deploy b. In the web service folder, right click on the web service -> Test web service. Step 7: Get into NetBeans IDE, go to File -> New Project -> Java -> Web Application Give the name of the project as “clientmarklist”. Step 8: Create a Home Page to receive sequence. Step 9: Create component necessary to invoke the service from the client e. Right click “clientmarklist” -> new -> WebServiceClient f. Click Browse and select the required service. Step 10: Build and Run the Web Application. PROGRAM: SERVER: package pack; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.ejb.Stateless; import java.sql.*; @WebService(serviceName = "mlws") @Stateless() public class mlws { @WebMethod(operationName = "getdetails") public double[] getdetails(@WebParam(name = "num") int num) { double a1[] =new double[6]; try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection c=DriverManager.getConnection("jdbc:derby://localhost:1527/studentdb","student","student"); Statement st=c.createStatement();
  • 44210205028 ResultSet rs=st.executeQuery("select * from APP.STUDENT where REG_NO="+num); while(rs.next()) { a1[0]=rs.getDouble("MATHS"); a1[1]=rs.getDouble("PHYSICS"); a1[2]=rs.getDouble("CHEMSITRY"); a1[3]=rs.getDouble("COMPUTER_SCIENCE"); a1[4]=a1[0]+a1[1]+a1[2]+a1[3]; a1[5]=a1[4]/4; } } catch(Exception ex) { } return a1; } @WebMethod(operationName = "getName") public String getName(@WebParam(name = "no")int no) { String name=""; try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection c=DriverManager.getConnection("jdbc:derby://localhost:1527/studentdb","student","student"); Statement st=c.createStatement(); ResultSet rs=st.executeQuery("select * from APP.STUDENT where REG_NO="+no+""); while(rs.next()) { name=rs.getString("NAME"); } } catch(Exception ex) {} return name; } @WebMethod(operationName = "getNo") public int getNo() { int no=0; try { Class.forName("org.apache.derby.jdbc.ClientDriver");
  • 44210205028 Connection c=DriverManager.getConnection("jdbc:derby://localhost:1527/studentdb","student","student"); Statement st=c.createStatement(); ResultSet rs=st.executeQuery("select * from APP.STUDENT"); while(rs.next()) { no=rs.getInt("REG_NO"); }} catch(Exception ex) { } return no; } } CLIENT: Index.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.util.*"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>student mark list</title> </head> <body> <h1>Student Details</h1> <hr/> <% try { a.Mlws_Service s=new a.Mlws_Service(); a.Mlws port=s.getMlwsPort(); %> <form method="get" action=second.jsp> <table border=2 align=center> <tr><th> REG_NO </th><th> NAME </th><th> MATHS </th><th>
  • 44210205028 PHYSICS </th><th> CHEMISTRY </th><th> COMPUTER_SCIENCE</th> </tr> <% for(int i=1;i<port.getNo();i++) { List<Double> l = port.getdetails(i); %> <tr><td> <%=i%> </td><td> <%=port.getName(i)%> </td><td> <%=l.get(0)%> </td><td> <%=l.get(1)%> </td><td> <%=l.get(2)%> </td><td> <%=l.get(3)%> </td></tr> <% } %> </table><br> <center>ENTER THE STUDENT NO FOR WHOM YOU WANT TO CALCULATE TOTAL AND PERCENTAGE</center><br> <input type=text name=id><br> <input type=submit value=SUBMIT> </form> <% } catch(Exception ex) { } %> </body> </html>
  • 44210205028 Second.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.util.*"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>student mark list</title> </head> <body> <h1>Student Details</h1> <hr/> <% try { a.Mlws_Service s=new a.Mlws_Service(); a.Mlws port=s.getMlwsPort(); %> <form action=first.jsp> <table border=2 align=center> <tr><th> REG_NO </th> <th>NAME</th> <th>MATHS</th> <th>PHYSICS </th> <th>CHEMISTRY</th> <th>COMPUTER_SCIENCE</th> <th>TOTAL</th> <th>PERCENTAGE</th> </tr> <% int i=Integer.parseInt(request.getParameter("id")); List<Double> l = port.getdetails(i); %> <tr> <td><%=i%></td> <td><%=port.getName(i)%></td> <td><%=l.get(0)%></td> <td><%=l.get(1)%></td> <td><%=l.get(2)%></td> <td><%=l.get(3)%></td> <td><%=l.get(4)%></td> <td><%=l.get(5)%></td> </tr> </table><br> <input type=submit value=BACK> </form>
  • 44210205028 <% } catch(Exception ex) { } %> <hr/> </body> </html> OUTPUT:
  • 44210205028 RESULT: Thus the Student marklist component has been created using EJB component as web service.
  • 44210205028 EX No: 3(d) DEVELOP COMPONENTS USING EJB COMPONENT TECHNOLOGY DATE: PAYROLL PROCESSING AIM: To develop payroll processing component using EJB component as a web service. ALGORITHM: Step 1: Go to NetBeans IDE-> File -> New Project -> Java EE -> EJB Module -> Next and name the project as “payroll” -> Next -> Finish. Step 2: Create new web service i. Right Click the created project name -> New -> Web Service -> Give name for the web service and package -> Finish. j. A new folder named “web services” will be created under the project folder. Inside that, new web services will be created. Step 3: Creating function for web service Under the web services folder, right click the web service created -> Add operation. *Give the appropriate name for the operation *Select the return type of the function *Adding parameters: Click Add -> Give name of the parameter and their data type. Click OK. Step 4: Write the required operation inside the function and also see to the return type matches. Write the required coding and save the file. _______________________________________________________________________ /* Sample Code */ @WebMethod(operationName=”getName”) Public String getName(@WebParam(name= “no”) int no) ________________________________________________________________________
  • 44210205028 Step 5: Right Click on the webservice -> Add Operation -> choose the operation name and return type. Step 6: a. Right Click the project -> Deploy b. In the web service folder, right click on the web service -> Test web service. Step 7: Get into NetBeans IDE, go to File -> New Project -> Java -> Web Application Give the name of the project as “clientpayroll”. Step 8: Create a Home Page to receive sequence. Step 9: Create component necessary to invoke the service from the client g. Right click “clientpayroll” -> new -> WebServiceClient h. Click Browse and select the required service. Step 10: Build and Run the Web Application. PROGRAM: SERVER: /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package pckg; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.ejb.Stateless; /** * * @author student */ @WebService(serviceName = "payservice") @Stateless() public class payservice { @WebMethod(operationName="calculate") public double[] calculate(@WebParam(name="basic")double basic,@WebParam(name="ded")double ded)
  • 44210205028 { double da,hra,gsal,pf,netsal; double a[]=new double[5]; da=(3*basic)/10; hra=1000; gsal=basic+da+hra; pf=(5*basic)/10+da+ded; netsal=gsal-pf; a[0]=da; a[1]=hra; a[2]=gsal; a[3]=pf; a[4]=netsal; return a; } } CLIENT: Index.jsp: <%-Document : index Created on : Sep 22, 2013, 2:08:18 AM Author : student --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Payment processing</h1> <form action="result1.jsp" method="get"><table> <tr> <td>Basic pay</td> <td><input type="text" name="sal"/> </td></tr> <tr><td>deduction</td> <td><input type="text" name="ded"/></td></tr> </table><br><center>
  • 44210205028 <input type="submit" value="enter"/> </center> </form> </body> </html> Result1.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>payroll processing</h1> <% try { pckg.Payservice_Service service=new pckg.Payservice_Service(); pckg.Payservice port=service.getPayservicePort(); double basic=Double.parseDouble(request.getParameter("sal")); double ded=Double.parseDouble(request.getParameter("ded")); java.util.List<java.lang.Double> result=port.calculate(basic,ded); java.util.ListIterator<Double> iter=result.listIterator(); %> <table> <tr> <td>Basic pay</td> <td><input type="text" value=<%=basic%>></td> </tr> <tr> <td>Deductions</td> <td><input type="text" value=<%=ded%>></td> </tr> <tr>
  • 44210205028 <td>DA</td> <td><input type="text" value=<%=iter.next()%>></td> </tr> <tr> <td>HRA</td> <td> <input type="text" value=<%=iter.next()%>></td> </tr> <tr> <td>GROSS </td> <td><input type="text" value=<%=iter.next()%>></td> </tr> <tr> <td>PF</td> <td><input type="text" value=<%=iter.next()%>> </td> </tr> <tr> <td>netpay</td> <td><input type="text" value=<%=iter.next()%>></td> </tr> </table> <% } catch(Exception e){} %> </body> </html>
  • 44210205028 OUTPUT:
  • 44210205028 RESULT: Thus the payroll processing component has been created using EJB component as web service.
  • 44210205028 EX No: 4 DATE: INVOKE EJB COMPONENTS AS WEB SERVICE TICKET RESERVATION AIM: To develop Ticket Reservation component using EJB component as a web service. ALGORITHM: Step 1: Go to NetBeans IDE-> File -> New Project -> Java EE -> EJB Module -> Next and name the project as “ticket” -> Next -> Finish. Step 2: Create new web service a. Right Click the created project name -> New -> Web Service -> Give name for the web service and package -> Finish. b. A new folder named “web services” will be created under the project folder. Inside that, new web services will be created. Step 3: Creating function for web service Under the web services folder, right click the web service created -> Add operation. *Give the appropriate name for the operation *Select the return type of the function *Adding parameters: Click Add -> Give name of the parameter and their data type. Click OK. Step 4: Write the required operation inside the function and also see to the return type matches. Write the required coding and save the file. -----------------------------------------------------------------------------------------------------------/* Sample Code */ @WebMethod(operationName=”getID”) Public int getID(@WebParam(name= “id”)int id) -----------------------------------------------------------------------------------------------------------Step 5: Right Click on the webservice -> Add Operation -> choose the operation name and return type. Step 6: a. Right Click the project -> Deploy c. In the web service folder, right click on the web service -> Test web service. Step 7: Get into NetBeans IDE, go to File -> New Project -> Java -> Web Application Give the name of the project as “clientticket”. Step 8: Create a Home Page to receive sequence.
  • 44210205028 Step 9: Create component necessary to invoke the service from the client d. Right click “clientticket” -> new -> WebServiceClient e. Click Browse and select the required service. Step 10: Build and Run the Web Application. PROGRAM: SERVER : Web Service /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package pack; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.ejb.Stateless; import java.sql.*; import javax.jws.Oneway; /** * * @author student */ @WebService(serviceName = "ticketserv") @Stateless() public class ticketserv {
  • 44210205028 String name=""; String time=""; int id,amount,qty,lastid; /** * Web service operation */ @WebMethod(operationName = "getid") public int getid(@WebParam(name = "id") int id) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/mydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.traintab where tid="+id); while(rs.next()) { id=rs.getInt("trainno"); }} catch(Exception e) {} return id; } /** * Web service operation */ @WebMethod(operationName = "getname") public String getname(@WebParam(name = "id") int id) { try
  • 44210205028 { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/mydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select name from APP.TRAINTAB where TRAINNO="+id); while(rs.next()) { name=rs.getString("name"); }} catch(Exception e) {} return name; } /** * Web service operation */ @WebMethod(operationName = "getamount") public int getamount(@WebParam(name = "id") int id) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/mydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.traintab where trainno="+id+""); while(rs.next()) { amount=rs.getInt("price");
  • 44210205028 }} catch(Exception e) {} return amount; } /** * Web service operation */ @WebMethod(operationName = "getqty") public int getqty(@WebParam(name = "id") int id) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/mydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.traintab where trainno="+id+""); while(rs.next()) { qty=rs.getInt("seatsavil"); }} catch(Exception e) {} return qty; } /** * Web service operation */ @WebMethod(operationName = "gettime")
  • 44210205028 public String gettime(@WebParam(name = "id") int id) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/mydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.traintab where trainno="+id+""); while(rs.next()) { time=rs.getString("Timings"); }} catch(Exception e) {} return time; } /** * Web service operation */ @WebMethod(operationName = "update") @Oneway public void update(@WebParam(name = "id") int id, @WebParam(name = "qty") int qty) { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/mydb","student","student"); Statement stmt=conn.createStatement();
  • 44210205028 stmt.executeUpdate("UPDATE APP.TRAINTAB SET SEATSAVL="+qty+"WHERE TRAINNO="+id+""); stmt.close(); } catch(Exception e) {} } /** * Web service operation */ @WebMethod(operationName = "getlastid") public int getlastid() { try { Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection conn=DriverManager.getConnection("jdbc:derby://localhost:1527/mydb","student","student"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from APP.traintab"); while(rs.next()) { lastid=rs.getInt("tid"); }} catch(Exception e) {} return lastid; } }
  • 44210205028 CLIENT: Index.jsp <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <%@page import="java.sql.*"%> <%@page import="java.io.*"%> <%@page import="java.util.*"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <center><h1>TRAIN DETAILS </h1></center> <hr/> <% try{ pack.Ticketserv_Service service=new pack.Ticketserv_Service(); pack.Ticketserv port=service.getTicketservPort(); %> <head> <body> <form action=second.jsp> <table border=2 align=center> <center> <tr><th>TRAIN_NO <th>NAME<TH>TIMINGS<th>SEATS_AVAILABLE<th>TICKET_PRICE</tr>
  • 44210205028 <% for(int i=1;i<=port.getlastid();i++) { int id=port.getid(i); int amount=port.getamount(id); int seats=port.getqty(id); String name=port.getname(id); String time=port.gettime(id); %> <tr><td><%=id%> <td><%=name%></td> <td><%=time%></td> <td><%=seats%></td> <td><%=amount%></td> </tr> <% } %> </center></table> ENTER THE TRAIN_NO:<input type=text name=<%=tid%>> <input type=submit value=SUBMIT> <% } catch(Exception e) {} %> <hr/> </body> </html>
  • 44210205028 Second.jsp: <%-Document : secondpage Created on : Sep 27, 2013, 2:23:24 AM Author : student --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <center><h1>TICKET RESERVATION</h1> <hr/> <% try { pack.Ticketserv_Service service=new pack.Ticketserv_Service(); pack.Ticketserv port=service.getTicketservPort(); %> <head> <body> <form action=thirdpage.jsp> <table border=2 align=center> <tr> <th>TRAIN_NO<th>NAME<th>TIMINGS<th>SEATS_AVAILABLE<th>TICKET_PRICE
  • 44210205028 </tr> <% int id=Integer.parseInt(request.getParameter("tid")); int amount=port.getamount(id); int seats=port.getqty(id); String name=port.getname(id); String time=port.gettime(id); %> <tr> <td><%=id %></td> <td><%=name%></td> <td><%= time %></td> <td><%=seats %></td> <td><%=amount%> </tr></table><br> ENTER THE Number OF SEATS:<input type=text name=<%=qty%>> <input type=hidden name=desc value=<%=name%>> <input type=hidden name=id value=<%=id%>> <input type=hidden name=avlqty value=<%=seats%>> <input type=hidden name=amount value=<%=amount%>> <input type=submit value=SUBMIT> <% } catch(Exception e) {} %>
  • 44210205028 </body> </html> Thirdpage.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>TICKET RESERVATION</h1> <% try { String name=request.getParameter("desc"); int id=Integer.parseInt(request.getParameter("id")); int qty=Integer.parseInt(request.getParameter("qty")); int amount=Integer.parseInt(request.getParameter("amount")); int avlqty=Integer.parseInt(request.getParameter("avlqty")); int netamount=amount*qty; if(avlqty<qty) { %> <h2> SEATS NOT AVAILABLE<head>
  • 44210205028 <body><form action=index.jsp> <input type=submit value=BACK> <% } else { %> <head><body><form action=finish.jsp> <h1>TRAIN NO:<%=id %><br> TRAIN NAME:<% =name%><br> <h3> AMOUNT: <%=netamount%><br><h4> ENTER THE CARD NUMBER:</h4> <input type=text> <input type=hidden name=id value=<%=id%>> <input type=hidden name=qty value=<%=qty%>> <input type=hidden name=avlqty value=<%=avlqty%>> <input type=submit value=SUBMIT> <%= }} catch(Exception e) {} %> </body> </html> Finish.jsp: <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <%!int i=0;%> <%=i++%>
  • 44210205028 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <center><h1>RESERVATION SUCCEDDED </h1></center> <hr/> <% try{ pack.Ticketserv_Service service=new pack.Ticketserv_Service(); pack.Ticketserv port=service.getTicketservPort(); int tno=i; int id=Integer.parseInt(request.getParameter("id")); int qty=Integer.parseInt(request.getParameter("qty")); int avlqty=Integer.parseInt(request.getParameter("avlqty")); qty=avlqty-qty; port.update(id, qty); %> <center>YOUR TICKET NUMBER: <%=tno%> } catch(Exception e) {} %> <hr/> </body> </html>
  • 44210205028 OUTPUT:
  • 44210205028
  • 44210205028
  • 44210205028
  • 44210205028 RESULT: Thus the ticket reservation component has been created by invoking EJB component as web service.
  • 44210205028 EX No: 5 DEVELOP A J2EE CLIENT TO ACCESS A .NET WEB SERVICE DATE: AIM: To develop a J2EE client to access a .NET service. ALGORITHM: 1. 1.Get into Visual studio new -> website->Asp.NET webservice choose language visual C# . give project name. 2. Code the service(for getOrder) Sample code [WebMethod] public int getOrderNumber(int seq) { Random r = new Random(); int ran = r.Next(); return ran; } 3. Right click->project->build website Click run for getting output
  • 44210205028 Click ->service.asmx
  • 44210205028
  • 44210205028 CREATION OF J2EE CLIENT TO ACCESS .NET WEB SERVICE 1. Get into NETBean IDE, Go to file -> New project -> java web application. Give name as orderapp. 2. Create homepage to receive sequence and call the servlet whch will in turn call the order webservice to generate order number. 3. Create the component necessary and invoke the service from the client by right clik on orderapp ->new -> webservice client. 4. Create a servlet to make a call to the order webservice by right click on orderapp project -> new ->servlet. Create a servlet to make a call to the order web service. Name it orderservlet. @WebServlet(name = "OrderServlet", urlPatterns = {"/ord"}) public class OrderServlet extends HttpServlet { @WebServiceRef(wsdlLocation = "WEBINF/wsdl/localhost_1444/WebSite2/Service.asmx.wsdl") private Service service;
  • 44210205028 /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { org.tempuri.ServiceSoap port=service.getServiceSoap(); int ornum=port.getOrderNumber(Integer.parseInt(request.getParameter("seq"))); out.println("<html><body><h1>Generate order number"+ornum+"</h1></body></html>"); } finally { out.close(); } } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs
  • 44210205028 */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// </editor-fold> private int getOrderNumber(int seq) { org.tempuri.ServiceSoap port = service.getServiceSoap(); return port.getOrderNumber(seq); } } 5. Drag and drop the webservice reference created frm step 3 in the servlet. Run the project
  • 44210205028 RESULT: Thus J2EE client is developed to access a .NET web service successfully.
  • 44210205028 EX No: 6 DEVELOP A .NET CLIENT TO ACCESS A J2EE WEB SERVICE DATE: AIM: To develop a .NET client to access a J2EE web service. ALGORITHM: 1. Get into the Netbean IDE, Go to File-> new Project -> Java web Application. Give the name of the project as OrderserviceApp->next. Click finish to end. 2. Right click OrderServiceApp project-> new-> webservice-> Give name as OrderWebserive, package name as samp and click finish. 3. Change the default web service with the code to generate ordernumber based on the sequence given as parameter. @WebMethod(operationName = "getOrderNumber") public int getOrderNumber(@WebParam(name = "name") int seq) { int ordernumber=(int)((Math.random()+seq)*10000000); return ordernumber; 4. Right click orderserviceapp project-> build and then deploy 5. Right click OrderWebService->test web service.
  • 44210205028 CREATION OD .NET CLIENT TO ACCESS J2EE WEB SERVICE 1. Get in visual studio new->website->ASP.NET website and choose language visual C# . give project name. 2. Right click->project->add web reference->give url of service press go. Web reference is created. 3. Go to default.aspx-> design view include a textbox and button to receive sequence and invoke service. On button click write the following code. protected void Button1_Click(object sender, EventArgs e) { ord.OrderWebService s = new ord.OrderWebService(); Response.Write(s.getOrderNumber(Convert.ToInt32(TextBox1.Text))); } Build solution-> publish website. 4.
  • 44210205028 RESULT: Thus a .NET client is created to access J2EE web service.
  • 44210205028 EX No: 7(a) DEVELOP A SERVICE ORCHESTRATION ENGINE USING WS BPEL AND IMPLEMENT SERVICE COMPOSITION FOR CALCULATOR DATE: AIM: To develop a service orchestration engine using ws bpel and implement service composition for calculator. CREATING A SERVICE 1. 2. 3. 4. 5. Create a web service in Netbeans 6.5 called calcservice. Open NetBeans6.5 , Select file-> Newproject-> javaEE-> EJB module. Click next. Right click on the project window and select New-> Webservice Name the service as calcservice. Pecify package as “pack”. Click on finish. Type the following code. CODE: package pack; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import javax.ejb.Stateless; public class calservice { @WebMethod(operationName = "add") public int add(@WebParam(name = "a") int a, @WebParam(name = "b") int b) { //TODO write your implementation code here: return a+b;
  • 44210205028 } } 6. Deploy the service and test the service. 7. Copy the WSDL URL.
  • 44210205028 CREATING A BPEL PROJECT 1. Click on File  new project and then click on SOA,then BPEL Name it as calcbpel.
  • 44210205028 2. Right click on the project, select new  BPEL process and name it calcprocess  Click finish.
  • 44210205028 3. Drag the item under web service in calcservice and drag to the partner link. 4. Fill the Name as PartnerlinkWS and leave the other values and click ok.
  • 44210205028 STEPS TO DO Creating another partner link : 1. Drag and drop the WSDL file again to the left hand side and name the partnerlink as partnerlinkbpel. 2. 3. 4. 5. 6. Click the Use a Newly Created Partner Link Type. Check process will implement MyRole. Fill the partner Link Type Name as calcServiceLinkTypeBPEL. Fill the Role Name as calcServiceRoleBPEL. Click on OK.
  • 44210205028 Design the BPEL as below : DRAG AND DROP the following entities from the palette.
  • 44210205028 Receive1.Assign1.Invoke1.Assign2.Reply1 in the order as below Receive1 and Reply1 others can be dragged later.
  • 44210205028 On Receive1 click on Edit.
  • 44210205028 Choose the partner Link as PartnerLinkBPEL and Operation as add. Click on create button besides Input Variable Label. The Name Is usually Addin.Leave it as such and click ok.
  • 44210205028 On reply1 repeat the same procedure to add a Addout variable as output.
  • 44210205028
  • 44210205028 Now Drag in Invoke1 and assign the properties as below.
  • 44210205028
  • 44210205028 Drag the Addin arguments on left side to Addin1 on the right side.
  • 44210205028 Now drag and drop Assign2 and then do the mapping of the return parameter from Addout on left side to AddOut on right side as below.
  • 44210205028 Map the parameters.
  • 44210205028 Creating a composite application : Click on New  Project  SOA  CompositeApplication and name it calccompositeapp.
  • 44210205028 Enter the name and location of the composite application. Now right click on the project  add a JBI Module.
  • 44210205028 Drag the BPEL process from the calcBPEL project and drop in the JBI window. Build the project.
  • 44210205028 Drag and drop soap entity from the palette and make the connections as below. Select and delete the existing connections. Establish the new connections as follows.
  • 44210205028 Then run the testcase after passing the value to the input file : Create a new test case and give a name for it. Click next. The related Wsdl documents will be displayed.
  • 44210205028 Expand the documents and select the relevant service and give next.
  • 44210205028 Finally select the operation to test and give finish.
  • 44210205028 The Ouput is generated as below: Now Build the BPEL project. Run the project. The following Xml document will be generated. Change the argument values.
  • 44210205028 The sum for the given values will be displayed. RESULT: Thus a service orchestration engine using WSBPEL and implement service composition for calculator is developed.
  • 44210205028 EX No: 7(b) DEVELOP A SERVICE ORCHESTRATION ENGINE(WORK FLOW) USING WS-BPEL AND IMPLEMENT SERVICE COMPOSITION FOR TRAVELS(AIRLINE) DATE: AIM: Develop a Service Orchestration engine(work flow) using WS-BPEL and implement service composition. To createa business process for planning business travels that will invoke several services. This process will invoke several airline companies to check the airfare price and buy at the lowest price. PROCEDURE: 1) Create a sample web application : File->new project-> in the catogories choose java web and in the projects tab select web application->click next-> give a name for that new web application in the project name (TestService1)-> accept the defaults and click finish.. In the projects tab our TestService1 has been created.
  • 44210205028 2)Creation of Web Service: Our web service reduces the amount by 5% and returns the value: Right click our TestService1from that select new webservice. Give appropriate name to that web service. Web service name:TestWebservice Package name: com.service Make sure that create web service from scratch is selected. Click finish. 3) Viewing for Our Web Service Our new TestService.java web service opens up Select the design tab->Click add operation
  • 44210205028 4) Creation of Operation for Our Web Service Our web service takes in amount reduces 5% tax in that and returns the amount. Input parameters:java.lang.Long Output parameters:java.lang.Long Operation name:TaxReduction Click the add operation->a new add operation box pops up->in tha name field:TaxService(operation name) return type: click the browse button->type long-> select java.lang.Long from the option parameters tab:InputAmount(NameFeild),long(Typefeild) click ok our TaxReduction operation shows up.->click the source view to write code
  • 44210205028 4) Paste the Code in our Operation double amt=InputAmount-(InputAmount*0.05); Long res=(new Double(amt)).longValue(); return res; 5) Click on the project tab there we can see our TestService web service in the web service folder. First right click the project and run the web application we created. RightClick->TestWebservice to test our web service
  • 44210205028 6) We can check our web service. Give any input value. Eg 15000
  • 44210205028 7) We get the output as 142500 Similarly create another web service CheckRange web service this checks the input amount and responds the type of travel based on the amount. Here is the code for that service. String res; if(parameter<=5000){ res="eligible for bus travell"; }else if(parameter>5000&&parameter<=10000){ res="eligible for train travell"; }else{ res="eligible for flight travell"; } return res;
  • 44210205028 7) BPEL CREATION File->new->new project->select soa in catogories andBPEL module in project Give a name for BPEL and accept the defaults. Now a project is created and we have to create a BPEL right click on the project we created new>BPEL Process Now give a name to our BPEL process and click finish. A sample BPEL file is created.
  • 44210205028 8) Now we need to create a client side interface to our BPEL process this is done by creating WSDL file specifying the input to BPEL process and output from BPEL process Right click project->new->new WSDL Specify the name of the WSDL in the file name->click next specify the inpu and output parameters in the WSDL ->cick next for our scenario long is the input and string is the output from our BPEL process ->click next-> finish Now a new WSDL client has been created for Sample BPEL process. Drag the WSDL created in our BPEL Design window 9) Now drag the receive from the palette box into the BPEL diagram
  • 44210205028 10) Drag the wire from receive to clientWSDL
  • 44210205028 11) Double click the receive and a new window opens click the create near the input variable a new variable input variable opens accept the defaults and click ok. 12) Now drag the reply and connect a wire from reply to clientWSDL as same as receive 13) When you double click the reply you will get a window click the create button make sure normal response is selected. Create new output variable opens. Click ok.
  • 44210205028 14) Now we have to create a partner link for web service invocation in our project. Go to the project tab and go to the web service we created. Right click the TestService webservice and select generate and copy WSDL. Select our BPEL project src folder and click ok.WSDL is copied into our BPEL project drag the WSDL into our BPEL editor. 15) We need to invoke our web service method into our BPEL process. So we need to drag a invoke method into BPEL between receive and reply now double click the invoke a new window opens. Select the partner link just created(partnerlink 1) it drops down the operation in that select the operation. click create for creating input variable.similarly for output variable.click ok
  • 44210205028 Similarly do the same for the next web Check rangeweb service we created.thus our BPEL should contain two service invocation.
  • 44210205028 Our BPEL process should first get the long amount from client and pass it to TaxReduction web service fro tax reduction and that output should be sent to checkrange service for checking range. The output from that checkrange service will be the output from out entire BPEL process 16) Now we have to assign the client input to TaxReductionservice.first drag a assign from palette and place it between receive and first invoke(TaxReduction). Double click assign . then mapper tab opens up. We have to assign the clientWSDLoperationinput to taxreductioninput. Click the clientWSDLoperationinput shows a part field.similarly click the Taxreduction operation in parameters field opensclick that once again inputamount opens.Just drag a wire frompart to inputamount.now we have assigned the BPEL input to taxreduction input. 17) Click on the design tab.now from taxreduction service to checkrange service.once again drap the assign and place between the taxreductioninvoke and checkrangeinvoke.
  • 44210205028 18) Finally place a assign block from checkRange service to reply
  • 44210205028 Overall BPEL process design will look like this. Now we have to specify the sopa address for the WSDLwe have imported. Select the imported WSDL files in BPEL you can see services in the navigator window
  • 44210205028 Select the SOAP address and copy the URL http://localhost:9401/TestService1/TaxServiceService http://localhost:9401/WebApplication4/NewWebServiceService in the place of actual URL 19) Right click our project and select clean and build . build sucessfull 20) Now we have to create a composite application to test our sample project File->new->new project->catogories(SOA) and projects(composite application)->next Give a name for our composite application and click finish
  • 44210205028 21) Right click the composite application just created and select add JBI module. Select the BPEL process just created CheckBPEL click on it project Jar field gets automatically updated.click add project jar file.
  • 44210205028 22) Once the jar has been added to your BPEL project just create a test case . Right click test and select a new test case1->browse to the client WSDL file and select it Select the operation then click finish. A new test case has been created and we can specify the input values through the input.xml file
  • 44210205028 Select the input and specify a value.say 12000. then right click the testcase1 and select run This prompts you with an alert box click yes. Thus our output has been got. RESULT: Thus a Service Orchestration engine(work flow) using WS-BPEL and implement service composition anda business process for planning business travels that will invoke several services is developed.