Showing posts with label SOA LAB. Show all posts
Showing posts with label SOA LAB. Show all posts

Friday, 8 November 2013

Develop a .NET Client to access J2EE Web Service



J2EE WEB SERVICE


package org.bursteg.calculator;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class CalculatorService
{
        @WebMethod
        public int Add(int a, int b)
        {
            return a + b;
        }

}




.NET CLIENT


static void Main(string[] args)
        {

Develop J2EE Client to access .NET Web Service




CODING:

Web Service:
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 exp6
{
    ///
    /// Summary description for Service1
    ///

    [WebService(Namespace = "http://tempuri.org/")]
    [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
    {

      

BPEL Module for SOA Project to compose WEB SERVICE



AIM:
         To Create a SOA project with BPEL Module to compose a web service.
SOFTWARE REQUIRED:
1.NetBeans 6.0.1 Version
ALGORITHM:
STEPS TO CREATE A BPEL MODULE

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 (for this example HelloWorld) and specify the project location or accept the defaults.

5. Click Finish.
The Projects window now contains a project node for the BPEL Module project.
Creating a BPEL Process Using the BPEL Designer

Invoking EJB Component as Web Service | SOA Lab Manual



1.       File à new project.
2.       In new project select javaEE à Enterprise application, then select next button.

3.       On clicking next button, a dialogue box appears asking us to enter project name.
Enter the project name as “Test1”  and click next.
4.       Another dialogue box appears asking us to choose the server and after choosing the server click the finish button.

5.       Right click on “Test1-ejb”, a menu pops out in which we choose new à session bean.
6.       A dialogue box will appear in which we give the ejb name as “TestEJB” and select the interface as remote and click finish button.

7.       After clicking the finish button a page with title TestEJB will appear, on the page perform right click operation and select “Insert codeà Business method”.

8.       A dialogue box appears in which we change the return type as String.


9.       Select Test1.war à Index.jsp , change the body as “ Click here to call EJB components.

10.   Right click Test1.waràNewàServlet.



11.   In that give the class name as “TestServlet” and package as “Servlets” and click on finish button.

Add these Header file
import java.io.*;
import javax.ejb.EJB;
import javax.servlet.*;
import javax.servlet.http.*;
import stateless.TestEJBRemote;
 
12.   In the Servlet page, right click à Insert code à Call Enterprise bean à TestEJBà Ok.
 
 
 
13.   In the same page change all the “processRequest” into “goGet” .
 
 
14.   Change the sixth “out.println“ statement into “out.println(TestEJBBean.getMessage())”;.





15.   Clean and build the project then execute the project.





Creating a Web Service in .NET | SOA Lab Manual




SOURCE CODE:
Service.cs
using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
public class Service : System.Web.Services.WebService
{
    public Service ()
    {}
    [WebMethod]
    public int add(int a, int b)
    {
        return a + b;
    }
    [WebMethod]
    public int sub(int a, int b)
    {
        return a - b;
    }
    [WebMethod]
    public int mul(int a, int b)
    {
        return a * b;
    }
    [WebMethod]
    public int div(int a, int b)
    {
        return a / b;
    }
   
}




Default.asp.cs
Top of Form
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;
public partial class _Default : System.Web.UI.Page
{  localhost.Service cal = new localhost.Service();
     protected void Button1_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.add(a, b);
        TextBox3.Text = c.ToString(); 
    }
    protected void Button2_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.sub(a, b);
        TextBox3.Text = c.ToString();
    }
 protected void Button3_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.mul(a, b);
        TextBox3.Text = c.ToString();
    }
 protected void Button4_Click(object sender, EventArgs e)
    {   int a = Int32.Parse(TextBox1.Text);
        int b = Int32.Parse(TextBox2.Text);
        int c = cal.div(a, b);
        TextBox3.Text = c.ToString();
    }



}




Online Shopping Program using C# .NET using 5 Components | SOA Lab Manual



Consoleapplication:

using System;
using System.Collections.Generic;
using System.Text;
using customer;
using computer;
using computerdetails;
using invoice;
using orderclass;
using bill;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string i;
int h;
Console.WriteLine("ONLINE SHOPPING");
Console.WriteLine("COMPUTER SALE");
Console.WriteLine("1.VIEW CATALOGUE");
Console.WriteLine("2.EXIT");
Console.WriteLine("ENTER YOUR CHOICE");
i = Console.ReadLine();
h = int.Parse(i);
switch (h)
{
case 1:
{
com o2 = new com();
o2.display1();
co_det O3 = new co_det();
O3.detail3();
cus o1 = new cus();
o1.display();
Corder o4 = new Corder();
o4.display4();
inv o5=new inv();
o5.display5();
bll x1 = new bll();
x1.billdisp();
Console.ReadLine();
}
break;
case 2:
break;
}}}}

Components:
computer:

using System;
using System.Collections.Generic;
using System.Text;
namespace computer
{
public class com
{
int a;
public void display1()
{
Console.WriteLine("COMPUTERS");
Console.WriteLine("1.dell");
Console.WriteLine("2.hcl");
Console.WriteLine("3.lava");
Console.WriteLine("4.sony");
Console.WriteLine("5.samsung");
}}}

Component:
computer details:

using System;
using System.Collections.Generic;
using System.Text;
namespace computerdetails
{
public class co_det
{
int d;
string w;
public void detail3()
{
Console.WriteLine("SELECT YOUR DESIRED COMPUTER");
w=Console.ReadLine();
d=int.Parse(w);
switch (d)
{
case 1:
{
Console.WriteLine("YOU HAVE SELECTED DELL");
Console.WriteLine("ITEM ID:09");
Console.WriteLine("ITEM PRICE:34,000");
Console.WriteLine("MODEL:INSPIRON");
}
break;
case 2:
{
Console.WriteLine("YOU HAVE SELECTED HCL");
Console.WriteLine("ITEM ID:59");
Console.WriteLine("ITEM PRICE:24,000");
Console.WriteLine("MODEL:ASPIRE");
}
break;
case 3:
{
Console.WriteLine("YOU HAVE SELECTED LAVA");
Console.WriteLine("ITEM ID:05");
Console.WriteLine("ITEM PRICE:55,000");
Console.WriteLine("MODEL:LAVA");
}
break;

case 4:
{
Console.WriteLine("YOU HAVE SELECTED SONY");
Console.WriteLine("ITEM ID:75");
Console.WriteLine("ITEM PRICE:23,000");
Console.WriteLine("MODEL:DEVINE");
}
break;
case 5:
{
Console.WriteLine("YOU HAVE SELECTED SAMSUNG");
Console.WriteLine("ITEM ID:03");
Console.WriteLine("ITEM PRICE:65,000");
Console.WriteLine("MODEL:GALLERY");
}
break;
case 6:
break;
}}}}

Component:
customer:

using System;
using System.Collections.Generic;
using System.Text;
namespace customer
{
public class cus
{
string name;
string add;
 string phno;
string email;
public void display()
{
int q;
string v;
Console.WriteLine("if you have conformed with this product fill the customer form");
Console.WriteLine("1.yes/2.no");
v=Console.ReadLine();
q=int.Parse(v);
switch(q)
{
case 1:
{
Console.WriteLine("enter your name:");
name = Console.ReadLine();
Console.WriteLine("enter your address:");
add = Console.ReadLine();
Console.WriteLine("enter your phone number:");
phno = Console.ReadLine();
Console.WriteLine("enter your email id:");
email = Console.ReadLine();
Console.WriteLine("CHECK YOUR DETAILS");
Console.WriteLine("");
Console.WriteLine("NAME={0}", name);
Console.WriteLine("ADDRESS={0}", add);
Console.WriteLine("PHONE NUMBER={0}", phno);
Console.WriteLine("EMAIL ID={0}", email);
Console.WriteLine("");
Console.ReadLine();
}
break;
case 2:
break;
}}}}

Component:
order:

using System;
using System.Collections.Generic;
using System.Text;
namespace orderclass
{
public class Corder
{
int s;
string f;
public void display4()
{Console.WriteLine("select payment method");
Console.WriteLine("1.CHEQUE/2.CASH");
f = Console.ReadLine();
s = int.Parse(f);
switch (s)
{case 1:
{Console.WriteLine("enter your account no:");
Console.ReadLine();
Console.WriteLine("name of bank:");
Console.ReadLine();
Console.WriteLine("your order conformed");}
break;
case 2:
{Console.WriteLine("your order conformed");
}
break;
case 3:
break;
 }}}}


Component:
invoice:

using System;
using System.Collections.Generic;
using System.Text;
namespace invoice
{public class inv
{public void display5()
{Console.WriteLine("YOUR PRODUCT WILL BE DELIVERED ON 12.9.2011");
Console.ReadLine();

}}}






Back To Top