soa-lab manual record

Upload: reddy007008

Post on 02-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Soa-lab Manual Record

    1/80

    Expt.: 1 .NET COMPONENT TECHNOLOGY

    Date: 1(a)EVEN OR ODD

    AIM:

    To write a .net program to print even and odd numbers within the givenlimit.

    ALGORITHM:

    1.

    Start the program

    2. Read the limit from user

    3. For i=0 to limit

    If i%2==0 print as even

    Else print as odd

    4.

    Stop the program

    CODING:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;namespace ConsoleApplication8

    {

    class Program

    {

    static void Main(string[] args)

    {

    int i;

    Console.WriteLine("Enter the limit: ");

    int n=int.Parse(Console.ReadLine());

    Console.WriteLine(Even numbers from 1 to +n);

    for (i = 2; i

  • 8/10/2019 Soa-lab Manual Record

    2/80

    }

    }

    OUTPUT:

    Enter the limit: 10Even numbers from 1 to 10

    2

    4

    6

    810

    Odd numbers from 1 to 10

    1

    3

    5

    7

    9

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    3/80

    Expt.: 1(b) ARITHMETIC OPERATIONS

    Date:

    AIM:

    To perform arithmetic operations using a .net program.

    ALGORITHM:

    1.

    Start the program

    2.

    Read the value for the variables

    3. Perform Arithmetic Operations

    4. Print the result5.

    Stop the program.

    CODING:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    namespace ConsoleApplication9

    {

    class Program

    {

    static void Main(string[] args)

    {float result;

    Console.WriteLine("Enter value for x:");

    int x=int.Parse(Console.ReadLine());

    Console.WriteLine("Enter value for y:");int y=int.Parse(Console.ReadLine());

    Console.WriteLine("Enter value for z:");

    int z=int.Parse(Console.ReadLine());

    Console.WriteLine("add");

    result = x + y + z;Console.WriteLine("x+y+z=" + result);

    Console.WriteLine("sub");

    result = x - y - z;

    Console.WriteLine("x-y-z=" + result);

    Console.WriteLine("multiplication");

    result = x * y * z;

    Console.WriteLine("x*y*z=" + result);Console.WriteLine("division");

    result = (float)x / y;Console.WriteLine("x/y=" + result);

  • 8/10/2019 Soa-lab Manual Record

    4/80

    Console.ReadLine();

    }

    }

    }

    OUTPUT:

    Enter value for x:

    75

    Enter value for y:

    50

    Enter value for z:2

    add

    x+y+z=127

    sub

    x-y-z=23

    multiplication

    x*y*z=7500

    division

    x/y=1.5

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    5/80

    Expt.: 1(c) CURRENCY CONVERSION

    Date:

    AIM:

    To write a .net program for currency conversion.

    ALGORITHM:

    1.

    Start the program

    2. Read the type of currency from user

    3. Read the value of currency.4.

    Convert the currency to Rupee value

    5.

    Print the result

    6.

    Stop the program

    PROGRAM:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    namespace ConsoleApplication2

    {

    class Program

    {static void Main(string[] args)

    {

    int ch;

    Console.WriteLine("\ncurrency conversion\n");do

    {

    Console.WriteLine("\n1.US dollars\n");

    Console.WriteLine("\n2.Europe\n");

    Console.WriteLine("\n3.australian\n");Console.WriteLine("\n4.canada\n");

    Console.WriteLine("\n5.new zealand\n");

    Console.WriteLine("\n6.exit\n");

    ch=int.Parse(Console.ReadLine());

    switch(ch)

    {

    case 1:Console.WriteLine("enter a dollar values");

    int usd=int.Parse(Console.ReadLine());double rud=usd*51.6150;

  • 8/10/2019 Soa-lab Manual Record

    6/80

    Console.WriteLine("rupees values");

    Console.WriteLine(rud);

    break;

    case 2:

    Console.WriteLine("enter a euro values");int eur=int.Parse(Console.ReadLine());

    double reur=eur*65.431;

    Console.WriteLine("rupees values");

    Console.WriteLine(reur);

    break;

    case 3:Console.WriteLine("enter a australian values");

    int avd=int.Parse(Console.ReadLine());

    double ravd=avd*32.09463;

    Console.WriteLine("rupees values");

    Console.WriteLine(ravd);

    break;

    case 4:

    Console.WriteLine("enter a canada values");

    int cad=int.Parse(Console.ReadLine());

    double rcad=cad*39.9621;

    Console.WriteLine("rupees values");

    Console.WriteLine(rcad);

    break;case 5:

    Console.WriteLine("enter a newzealand values");

    int nzd=int.Parse(Console.ReadLine());

    double rnzd=nzd*25.6974;Console.WriteLine("rupees values");

    Console.WriteLine(rnzd);

    break;

    case 6:

    break;default:

    break;

    }

    }

    while(ch>0&&ch

  • 8/10/2019 Soa-lab Manual Record

    7/80

    OUTPUT:

    currency conversion

    1.US dollars

    2.Europe

    3.australian4.canada5.new zealand

    6.exit

    1

    enter a dollar values20

    rupees values

    1032.3

    1.US dollars

    2.Europe

    3.australian

    4.canada

    5.new zealand

    6.exit

    2

    enter a euro values20

    rupees values

    1308.62

    1.US dollars

    2.Europe

    3.australian

    4.canada

    5.new zealand6.exit

    3

    enter a australian values

    20

    rupees values

    641.8926

  • 8/10/2019 Soa-lab Manual Record

    8/80

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    9/80

    Expt.: 1(d) PROGRAM TO IMPLEMENT COLLECTIONS USING

    Date: STACK

    AIM:

    To write a .net program to implement collections using stack.

    ALGORITHM:

    1.

    Start the program

    2.

    Create a Stack object

    3. Input values into stack using push()

    4. Remove the top value from stack using pop()5.

    Get the top value from stack using peek()

    6.

    Stop the program

    PROGRAM:

    using System;

    using System.Collections;

    using System.Linq;

    using System.Text;

    namespace prav

    {

    class Program

    {

    static void Main(string[] args){

    Stack s1 = new Stack();

    s1.Push(10);

    s1.Push(20);s1.Push(30);

    s1.Push(40);

    Console.WriteLine(s1.Pop());

    Console.WriteLine(s1.Peek());

    Console.WriteLine(s1.Pop());Console.ReadLine();

    }

    }

    }

  • 8/10/2019 Soa-lab Manual Record

    10/80

    OUTPUT:

    40

    30

    30

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    11/80

    Expt.: 1(e) SIMPLE DELEGATE PROCESSING

    Date:

    AIM:

    To write a .Net application program for Simple delegate processing.

    ALGORITHM:

    1.

    Start the program

    2.

    Create a delegate and instantiate an object for it.

    3. Implement three functions and pass these functions as parameters to the

    delegate.4.

    Call the functions using delegate object.

    5.

    Stop the program

    PROGRAM:

    using System;

    delegate void disp();

    class program

    {

    static void d1()

    {

    Console.WriteLine("a");

    }

    static void d2(){

    Console.WriteLine("b");

    }

    static void d3(){

    Console.WriteLine("c");

    }

    static void Main(string[] args)

    {disp d;

    d = new disp(d1);

    d += new disp(d2);

    d += new disp(d3);

    d();

    Console.ReadLine();

    }}

  • 8/10/2019 Soa-lab Manual Record

    12/80

    OUTPUT:

    a

    b

    c

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    13/80

  • 8/10/2019 Soa-lab Manual Record

    14/80

    OUTPUT:

    55

    6565

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    15/80

    Expt.: 2(a) DEVELOP AN ARITHMETIC WEB SERVICE USING J2EE

    Date: TECHNOLOGIES

    AIM:

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

    ALGORITHM:

    1.

    Using the Netbeans API create a project of the type web application.

    2.

    Create a web service in the project.

    3. Click on the Design tab and design the prototype of the web service.

    4. Click on source tab and modify the application logic of the web service.5.

    Save the project.

    6.

    Right click on the project and click on deploy and undeploy.

    7.

    Then test the web service.

    STEPS TO CREATE ADDITION WEB SERVICE:

    1. OPEN FileNewNewProjectWebWeb App...Click next

  • 8/10/2019 Soa-lab Manual Record

    16/80

    2.Give Project nameaddserverthen click finish

    3. The addserver project will be created in right side. Right click it and choose

    the following.

    Give the web service name as addweb.

  • 8/10/2019 Soa-lab Manual Record

    17/80

    4. After this in left side, the design window choose the add operation

    5. Give the following in the opened window for creating operation

    Nameadd

  • 8/10/2019 Soa-lab Manual Record

    18/80

    6.Then in the source add the following code and save it.

    package org;

    import javax.jws.WebMethod;

    import javax.jws.WebParam;import javax.jws.WebService;@WebService()

    public class addweb {

    /**

    * Web service operation

    */@WebMethod(operationName = "add")

    public int add(@WebParam(name = "a")

    int a, @WebParam(name = "b")

    int b) {

    return a+b;

    }

    }

    7. Then right click on add addserver and perform undeploy and deployafter

    that right click on addweb and do test web service to see the SOAP request and

    response message.

  • 8/10/2019 Soa-lab Manual Record

    19/80

    OUTPUT:

    Give some integers and click add.

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    20/80

    Expt.: 2(b) DEVELOP AN TEMPERATURE CONVERSION WEB

    Date: SERVICE USING J2EE TECHNOLOGIES

    AIM:

    To create a web service for an Temperature conversion using NetBeans.

    ALGORITHM:

    1.

    Using the Netbeans API create a project of the type web application.

    2.

    Create a web service in the project.

    3. Click on the Design tab and design the prototype of the web service.

    4. Click on source tab and modify the application logic of the web service.5.

    Save the project.

    6.

    Right click on the project and click on deploy and undeploy.

    7.

    Then test the web service.

    STEPS TO CREATE CONVERSION WEB SERVICE:

    1. NetBeans 6.9.1-> File-> New Project

  • 8/10/2019 Soa-lab Manual Record

    21/80

    2. Java Web->Web Application->Project name-> Next-> Finish

  • 8/10/2019 Soa-lab Manual Record

    22/80

    3. WebApplication-> New-> WebService-> WebServiceName->PackageName

  • 8/10/2019 Soa-lab Manual Record

    23/80

    4. NewWebService->AddOperation->Name->Parameters

    5.Rename operation name into conversion with return type double

  • 8/10/2019 Soa-lab Manual Record

    24/80

    6.Then in the source add the following code and save it.

    package org;

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

    /**

    *

    * @author Administrator*/

    @WebService()

    public class NewWebService {

    /**

    * Web service operation

    */

    @WebMethod(operationName = "conversion")

    public double conversion(@WebParam(name = "f")

    double f) {

    //TODO write your implementation code here:

    return f-32/1.8;

    }

    }

  • 8/10/2019 Soa-lab Manual Record

    25/80

    7. WebApplication->Deploy

    8. NewWebService->Test WebService (after successful build)

  • 8/10/2019 Soa-lab Manual Record

    26/80

    OUTPUT:

  • 8/10/2019 Soa-lab Manual Record

    27/80

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    28/80

    Expt.: 2(c) CREATE A J2EE CLIENT TO ACCESS THE J2EE

    Date: WEB SERVICE

    AIM:

    To create a J2EE web service for adding few numbers using NetBeans and writeJ2EE client side code to invoke the web service.

    ALGORITHM:

    1.

    Using the Netbeans API create a project of the type web application.

    2. Create a web service in the project.

    3. Click on the Design tab and design the prototype of the web service.4.

    Click on source tab and modify the application logic of the web service.

    5.

    Save the project.

    6.

    Right click on the project and click on deploy and undeploy.

    7.

    Then test the web service.

    8. Create another web application project and create a jsp file.

    9. Right click on project and click on create web service client.

    10.

    Browse and choose the web service created i.e. wsdl url

    11.

    Then pass the appropriate parameters to the web service client and invoke

    the web service.

    STEPS TO CREATE ARITHMETIC WEB SERVICE:

    1. OPEN FileNewNewProjectWebWeb App...Click next

  • 8/10/2019 Soa-lab Manual Record

    29/80

    2. Give Project namearithmeticthen click finish

    3.The addserver project will be created in left side. Right click it and choose the

    following.

    Arithmetic (right click)newweb service.

  • 8/10/2019 Soa-lab Manual Record

    30/80

    4.Give the web service name as addition.

    Give the package name as org.

    5.After this in left side ,the design window choose the add operation

    Addition(rightclick)add operation

    6. Give the following in the opened window for creating operation

    Nameadd,return typeint.Create two parameters a & b with the return type int.

  • 8/10/2019 Soa-lab Manual Record

    31/80

    7.Then in the source add the following code and save it.package org;

    import javax.jws.WebMethod;

    import javax.jws.WebParam;

    import javax.jws.WebService;

    @WebService()

    public class addition {

    /**

    * 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;

    }

    }

  • 8/10/2019 Soa-lab Manual Record

    32/80

    8. right click on add arithmetic project and perform undeploy and deploy.

    9. right click on addition web servicetest web service to see the SOAPrequest and response message.

  • 8/10/2019 Soa-lab Manual Record

    33/80

    10.Give some integers and click add.

  • 8/10/2019 Soa-lab Manual Record

    34/80

  • 8/10/2019 Soa-lab Manual Record

    35/80

  • 8/10/2019 Soa-lab Manual Record

    36/80

  • 8/10/2019 Soa-lab Manual Record

    37/80

    5.Then choose addition service

    Then click finish .now arithmetic service is imported into client program.

  • 8/10/2019 Soa-lab Manual Record

    38/80

    6.Then choose the following and add the source code in index.jsp and save it.

    (Rightclick)index.jspweb service client resoursescall web service

    operation.

    7.Then invoke the add operation.

    8.Code will be generated and give the input valuesrun

  • 8/10/2019 Soa-lab Manual Record

    39/80

    JSP Page

    Hello World!

  • 8/10/2019 Soa-lab Manual Record

    40/80

    OUTPUT:

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    41/80

    Expt.: 3 INVOKE .NET COMPONENT AS WEB SERVICE

    Date:

    AIM:

    To create a .NET web service for adding few numbers and to writeclient side .NET code to invoke the web service.

    ALGORITHM:1.

    Using the Visual studio2008 API create a project of the type Asp .NET

    Webservice Application .

    2. Create a web service in the project.3.

    Click on source tab and modify the application logic of the web service.

    4.

    Save the project and run the project.

    5.

    Create another console application project using VisualStudio2008 and

    create a cs file.

    6. Right click on project and click on Add Web Reference.

    7. Copy and paste the WDDL url in the reference tab .

    8.

    Modify the program.cs code.

    9.

    Then pass the appropriate parameters to the program.cs and invoke the

    web service.

  • 8/10/2019 Soa-lab Manual Record

    42/80

    STEPS TO CREATE A .NET WEB SERVICE:

    1.OPEN FileNewProjectVisual c# type Asp .NET Webservice

    Application..click next

    2.Give Project namearithmeticthen click ok

    3.modify the Service1.asmx.cs file as below and click run

    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 arrithmatic{

  • 8/10/2019 Soa-lab Manual Record

    43/80

    ///

    /// 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

    {

    [WebMethod]

    public int add(int a,int b)

    {

    return a+b;

    }

    }

    }

    4.click operation in browser , pass the values and click invoke.

  • 8/10/2019 Soa-lab Manual Record

    44/80

    5.click service description in browser to view the wsdl file

    STEPS TO CREATE CLIENT .NET SIDE PROJECT:

    1.OPEN FileNewProjectVisual c#Console Application..click next

    2. Give Project namearithmeticclientthen click ok

  • 8/10/2019 Soa-lab Manual Record

    45/80

    3.arrithmeticclient project will be created. right click it and choose the

    following.

    arithmeticclientAdd Service Reference.

    4.click advanced button from Add Service Reference.

  • 8/10/2019 Soa-lab Manual Record

    46/80

    5.click Add Web Refernce from the next window of Service Reference Settings

    6.copy and paste the Addition services WSDL urlclick Go

    Rename the web reference name as webreferencethe click Add Reference

  • 8/10/2019 Soa-lab Manual Record

    47/80

    now arithmetic service is imported into client program.

    7.modify the arithmeticclient.cs as follows and run the project

    using System;

    using System.Collections.Generic;using System.Linq;using System.Text;

    using arrithmaticclient.webreference;

    namespace arrithmaticclient

    {class Program

    {

    static void Main(string[] args)

    {

    Service1 webservice = new Service1();

    Console.WriteLine(webservice.add(4, 5));

    Console.ReadLine();

    }

    }

    }

  • 8/10/2019 Soa-lab Manual Record

    48/80

    OUTPUT:

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    49/80

    Expt.: 4 INVOKE EJB COMPONENT AS WEB SERVICE

    Date:

    AIM:

    To create a simple message component using EJB component technology.

    PROCEDURE:

    1.

    Create an Enterprise application project in netbeans IDE.

    a)

    To do that, go to the tab Projects and right mouse click and

    select option New Project. On the new screen, select the Category

    Enterprise and then the project Enterprise Application, click next to go to

    the next screen.

    b)

    On the next screen select the Project name and the Project

    Location. (for example give project name is Test), click next again.

    2.

    Create Stateless Session Bean using EJB.

    a)

    On the Projects tab, expand the EJB module ("Test-ejb"). Right

    mouse click onEnterprise Beans -> New -> Session Bean.

    b)

    On the screen that will come up, choose the EJB Name,

    Package, Session Type and Interface. For example,

    "TestEJB","stateless","Stateless","Remote". Click finish.

    c)

    After the Session Bean is created, you will see the class and the

    interface in the Source Packages section, as well as the Bean in the

    Enterprise Beans section. In the main tab, the TestEJBBean.java will be

    opened automatically.

    d)

    In the body of the class there is a comment " // Add business

    logic below. (Right-click in editor and choose // "EJB Methods > Add

    Business Method")"

    e)

    A new screen will come up. We are creating a method (called

    getMessage()) with String return. Hence, put in the field name

    getMessage and return type: String.

  • 8/10/2019 Soa-lab Manual Record

    50/80

    f)

    Add the return a string message in getMessage method: Hello

    EJB World. The code looks like below:

    package stateless;

    import javax.ejb.Stateless;

    @Stateless

    public class TestEJBBean implements TestEJBRemote {

    public String getMessage() {

    return "Hello EJB World";

    }

    }

    3.

    Create EJB client.

    a)

    We have already created the Web Module when the EAR has

    been created, so lets use it as EJB Client.

    b)

    When the Web module is created, by default Netbeans already

    creates a file called index.jsp in the Web Pages section. Open this file to

    add a call to the servlet. The code looks like below:

    JSP Page

    Hello World!

    Click here to call the EJB component

  • 8/10/2019 Soa-lab Manual Record

    51/80

    4.

    Create a servlet called TestServlet. it will call the EJB component when the

    link from User Interface is clicked.

    a)

    To create the servlet , right click on Web project (for example,

    Test-web), New -> Servlet.

    b)

    The code from Servlet looks like below:

    package servlets;

    import java.io.*;

    import javax.ejb.EJB;

    import javax.servlet.*;

    import javax.servlet.http.*;

    import stateless.TestEJBRemote;

    public class TestServlet extends HttpServlet {

    //This annotation INJECTS the TestEJBRemove object from EJB

    //into this attribute

    @EJB

    private TestEJBRemote testEJB;

    protected void doGet(HttpServletRequest request,

    HttpServletResponse response) throws ServletException,

    IOException {

    response.setContentType("text/html;charset=UTF-8");

    PrintWriter out = response.getWriter();

    out.println("");

    out.println("");

    out.println("Servlet TestServlet");

    out.println("");

    out.println("");

  • 8/10/2019 Soa-lab Manual Record

    52/80

    out.println(testEJB.getMessage());

    out.println("");

    out.println("");

    }

    }

    5. Running the code

    Right click on EAR project (in this case Test) and select option Run.

  • 8/10/2019 Soa-lab Manual Record

    53/80

    OUTPUT:

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    54/80

  • 8/10/2019 Soa-lab Manual Record

    55/80

  • 8/10/2019 Soa-lab Manual Record

    56/80

    5) Select Windows from menu bar->reset windows.

    6) Choose helloworldprocess.bpel navigator-> Right click helloworldprocess->add ->partner link->ok

  • 8/10/2019 Soa-lab Manual Record

    57/80

    7) Drag the receive from the web service to the helloworldprocess. Click Edit->

    name as start-> select partner link->click create->ok.

    8) Drag the reply from the web service to the helloworldprocess. Click Edit->

    name as end -> select partner link->click create->ok.

  • 8/10/2019 Soa-lab Manual Record

    58/80

    9) Drag the assign from basic activities to the helloworldprocess between

    receive and reply-> bpel mapper will appear-> drag the connection between

    newWSDLoperation in to newWSDL operationout.

    STEPS TO DEPLOY BPEL MODULE

    10) File->new project-> select SOA from categories and composite applicationfrom projects ->click next

  • 8/10/2019 Soa-lab Manual Record

    59/80

    11) Right click composite application from project window-> add JBI module->

    select helloworld->jarfile->click Add project jar files.

    12) right click test from composite application->add test cases->next->select

    BPEL process-> next->WSDL operation-> finish. Accept the default test casename, TestCase1, and click next.

    Run the test case->

    In the Projects window, right-click the TestCase1 node and choose Run from

    the pop-up menu.

  • 8/10/2019 Soa-lab Manual Record

    60/80

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    61/80

    Expt. : 6 CREATE A J2EE CLIENT TO ACCESS THE .NET WEB

    Date: SERVICE

    AIM:

    To create a .NET web service for adding few numbers and write a J2EEclient side code to invoke the web service.

    ALGORITHM:

    1.

    Using the Visual studio2008 API create a project of the type Asp .NET

    Webservice Application .

    2. Create a web service in the project.3.

    Click on source tab and modify the application logic of the web service.

    4.

    Save the project and run the project.

    5.

    Create web application project using Netbeans and create a jsp file.

    6.

    Right click on project and click on create web service client.

    7. Paste the wsdl url in the project and

    8. Drag and drop the web service reference to the source code window.

    9.

    Then pass the appropriate parameters to the web service client and invoke

    the web service.

  • 8/10/2019 Soa-lab Manual Record

    62/80

    STEPS TO CREATE A .NET WEB SERVICE:

    1.OPEN FileNewProjectVisual c# type Asp .NET Webservice

    Application..click next

    2. Give Project namearithmeticthen click ok

    3.Modify the Service1.asmx.cs file as below and click run

    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 arrithmatic

    { ///

  • 8/10/2019 Soa-lab Manual Record

    63/80

    /// 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

    {

    [WebMethod]

    public int add(int a,int b)

    {

    return a+b;

    }

    }

    }

    4.click operation in browser , pass the values and click invoke.

  • 8/10/2019 Soa-lab Manual Record

    64/80

    5.click service description in browser to view the wsdl file

    STEPS TO CREATE CLIENT SIDE PROJECT:

    1.OPEN FileNewNewProjectWebWeb App..click next

  • 8/10/2019 Soa-lab Manual Record

    65/80

    2. Give Project namearrithmeticclientthen click finish

    3. addclient project will be created. right click it and choose the following.

    ArithmeticclientnewWeb Service Client.

  • 8/10/2019 Soa-lab Manual Record

    66/80

    4.Then paste the addition wsdl url in the WSDL URLclick SetProxy click

    ok

  • 8/10/2019 Soa-lab Manual Record

    67/80

    5.Then choose add operationclick ok

    now arithmetic service is imported into client program.

    6.Code will be generated and give the input valuesrun

    JSP Page

  • 8/10/2019 Soa-lab Manual Record

    68/80

    Hello World!

    \

  • 8/10/2019 Soa-lab Manual Record

    69/80

    OUTPUT:

    RESULT:

  • 8/10/2019 Soa-lab Manual Record

    70/80

    Expt.: 7 CREATE A .NET CLIENT TO ACCESS THE J2EE

    Date: WEB SERVICE

    AIM:

    To create a J2EE web service for adding few numbers usingNetBeans and write .NET client side code to invoke the web service.

    ALGORITHM:

    1.

    Using the Netbeans API create a project of the type web application.

    2. Create a web service in the project.

    3. Click on the Design tab and design the prototype of the web service.4.

    Click on source tab and modify the application logic of the web service.

    5.

    Save the project.

    6.

    Right click on the project and click on deploy and undeploy.

    7.

    Then test the web service.

    8. Create another console application project using VisualStudio2008 and

    create a cs file.

    9.

    Right click on project and click on Add Web Reference.

    10.

    Copy and paste the WDDL url in the reference tab .

    11.

    Modify the program.cs code.

    12. Then pass the appropriate parameters to the program.cs and invoke the

    web service.

    STEPS TO CREATE ARRITHMETIC WEB SERVICE:

    1.OPEN FileNewNewProjectWebWeb App..click next

  • 8/10/2019 Soa-lab Manual Record

    71/80

    2. Give Project namearithmeticthen click finish

    3. The addserver project will be created in left side. Right click it and choose the

    following.Arithmetic (right click)newweb service.

  • 8/10/2019 Soa-lab Manual Record

    72/80

    4. Give the web service name as addition.

    Give the package name as org.

    5. After this in left side, the design window choose the add operationAddition (right click)add operation

  • 8/10/2019 Soa-lab Manual Record

    73/80

    6. Give the following in the opened window for creating operation

    Nameadd, return typeint.

    Create two parameters a & b with the return type int.

    7. Then in the source add the following code and save it.

    Package org;

    import javax.jws.WebMethod;import javax.jws.WebParam;

    import javax.jws.WebService;

    @WebService()

    public class addition {

    /**

    * 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;

  • 8/10/2019 Soa-lab Manual Record

    74/80

    }

    }

    8. Right click on add arithmetic project and perform undeploy and deploy.

    9. Right click on addition web service test web service to see the SOAP

    request and response message.

  • 8/10/2019 Soa-lab Manual Record

    75/80

    10. Give some integers and click add.

  • 8/10/2019 Soa-lab Manual Record

    76/80

  • 8/10/2019 Soa-lab Manual Record

    77/80

    3.arrithmeticclient project will be created. right click it and choose the

    following.

    arithmeticclientAdd Service Reference.

    4.click advanced button from Add Service Reference.

  • 8/10/2019 Soa-lab Manual Record

    78/80

    5.click Add Web Refernce from the next window of Service Reference Settings

    6.copy and paste the Addition services WSDL urlclick Go

    Rename the web reference name as webreferencethe click Add Reference

  • 8/10/2019 Soa-lab Manual Record

    79/80

    now arithmetic service is imported into client program.

    7.modify the program.cs as follows and run the project

    using System;using System.Collections.Generic;using System.Linq;

    using System.Text;

    using arithmaticcient.webreference;

    namespace arithmaticcient

    {

    class Program

    {

    static void Main(string[] args)

    {

    additionservice webservice = new additionservice();

    Console.WriteLine(webservice.add(6,3));

    Console.ReadLine();

    }

    }

    }

  • 8/10/2019 Soa-lab Manual Record

    80/80

    OUTPUT: