Download as pdf or txt
Download as pdf or txt
You are on page 1of 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 given
limit.

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 <= n; i++)
{
if (i % 2 == 0)
Console.WriteLine(i);
}
Console.WriteLine(Odd numbers from 1 to +n);
for (i = 1; i <= n; i++)
{
if (i % 2 != 0)
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}

OUTPUT:

Enter the limit: 10
Even numbers from 1 to 10
2
4
6
8
10

Odd numbers from 1 to 10
1
3
5
7
9

















RESULT:






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 result
5. 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);
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:





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;
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<6);
}
}



OUTPUT:
currency conversion
1.US dollars
2.Europe
3.australian
4.canada
5.new zealand
6.exit

1
enter a dollar values
20
rupees values
1032.3

1.US dollars
2.Europe
3.australian
4.canada
5.new zealand
6.exit

2
enter a euro values
20
rupees values
1308.62

1.US dollars
2.Europe
3.australian
4.canada
5.new zealand
6.exit

3
enter a australian values
20
rupees values
641.8926







































RESULT:






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();
}
}
}







OUTPUT:
40
30
30































RESULT:






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();
}
}



OUTPUT:
a
b
c































RESULT:






Expt.: 1(f) PROGRAM TO IMPLEMENT COLLECTIONS USING
Date: QUEUE

AIM:
To write a .net program to implement collections using queue.

ALGORITHM:
1. Start the program
2. Create a Queue object
3. Input values into queue using Enqueue()
4. Remove the top value from stack using Dequeue()
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 queue
{
class queue1
{
static void Main(string[] args)
{
Queue q1 = new Queue();
q1.Enqueue(55);
q1.Enqueue(65);
q1.Enqueue(75);
q1.Enqueue(85);
Console.WriteLine(q1.Dequeue());
Console.WriteLine(q1.Peek());
Console.WriteLine(q1.Dequeue());
Console.ReadLine();
}
}
}







OUTPUT:

55
65
65






























RESULT:






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







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.







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




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.






OUTPUT:

Give some integers and click add.








RESULT:






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




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










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








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




5.Rename operation name into conversion with return type double



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

}

















7. WebApplication->Deploy






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




OUTPUT:





















RESULT:





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 write
J2EE 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







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.






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 type int.
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. 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.









10.Give some integers and click add.



















STEPS TO CREATE CLIENT SIDE PROJECT:

1.OPEN FileNewNewProjectWebWeb App..click next





2. Give Project namearrithmeticclientthen click finish






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





4.Then browse and choose the addition wsdl file from the Project







5.Then choose addition service







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






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

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%-- start web service invocation --%><hr/>
<%
try {
org.AdditionService service = new org.AdditionService();
org.Addition port = service.getAdditionPort();
// TODO initialize WS operation arguments here
int a = 5;
int b = 7;
// TODO process result here
int result = port.add(a, b);
out.println("Result = "+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
%>
<%-- end web service invocation --%><hr/>
</body>
</html>















OUTPUT:




















RESULT:







Expt.: 3 INVOKE .NET COMPONENT AS WEB SERVICE
Date:

AIM:
To create a .NET web service for adding few numbers and to write
client 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.























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
{
/// <summary>
/// Summary description for Service1
/// </summary>
[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.




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



3.arrithmeticclient project will be created. right click it and choose the
following.
arithmeticclientAdd Service Reference.



4.click advanced button from Add Service Reference.




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



6.copy and paste the Addition services WSDL url click Go
Rename the web reference name as webreferencethe click Add Reference




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();
}
}
}






















OUTPUT:














RESULT:






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 on Enterprise 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.
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:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
<a href="TestServlet">Click here to call the EJB component</a>
</body>
</html>
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("<html>");
out.println("<head>");
out.println("<title>Servlet TestServlet</title>");
out.println("</head>");
out.println("<body>");
out.println(testEJB.getMessage());


out.println("</body>");
out.println("</html>");
}
}
5. Running the code
Right click on EAR project (in this case Test) and select option Run.





















OUTPUT:










RESULT:





Expt.: 5 CREATION OF BPEL MODULE AND A COMPOSITE
Date: APPLICATION

AIM:
To develop a Service Orchestration Engine (workflow) using WS-
BPEL and implement service composition.

STEPS TO CREATE BPEL MOBULE

1) File->new project-> select SOA from categories and WBPEL module from
projects->click next



2) Give project name as helloworld -> Finish

3) Right click helloworld in the project window->new->BPEL process-> give
the name of process as helloworld process -> Finish.




4) Right click helloworld in project window->new ->WSDL document -> file
name as synchronous-> Finish.






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




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






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.






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 application
from projects ->click next




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 case
name, 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.









































RESULT:






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 J2EE
client 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.
























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
{
/// <summary>
/// Summary description for Service1
/// </summary>
[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.






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





STEPS TO CREATE CLIENT SIDE PROJECT:

1.OPEN FileNewNewProjectWebWeb App..click next





2. Give Project namearrithmeticclientthen click finish







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






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









5.Then choose add operation click ok



now arithmetic service is imported into client program.

6.Code will be generated and give the input valuesrun

<%--
Document : index
Created on : 2 Oct, 2011, 9:41:21 AM
Author : INDISS
--%>

<%@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>Hello World!</h1>
<%-- start web service invocation --%><hr/>
<%
try {
org.tempuri.Service1 service = new org.tempuri.Service1();
org.tempuri.Service1Soap port = service.getService1Soap();
// TODO initialize WS operation arguments here
int a = 5;
int b = 2;
// TODO process result here
int result = port.add(a, b);
out.println("Result = "+result);
} catch (Exception ex) {
// TODO handle custom exceptions here
}
%>
<%-- end web service invocation --%><hr/>
</body>
</html>
\























OUTPUT:














RESULT:






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

AIM:
To create a J2EE web service for adding few numbers using
NetBeans 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

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.






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 (right click) add operation






6. Give the following in the opened window for creating operation
Nameadd, return type int.
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. 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.






10. Give some integers and click add.

















STEPS TO CREATE CLIENT .NET SIDE PROJECT:

1.OPEN FileNewProjectVisual c#Console Application..click next
2. Give Project namearithmeticclientthen click ok



3.arrithmeticclient project will be created. right click it and choose the
following.
arithmeticclientAdd Service Reference.


4.click advanced button from Add Service Reference.








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




6.copy and paste the Addition services WSDL url click Go
Rename the web reference name as webreferencethe click Add Reference



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();
}
}
}




















OUTPUT:













RESULT:

You might also like