0% found this document useful (0 votes)
57 views

WXML Programs

WXML programs can be used to create a variety of interactive and engaging experiences. They are a powerful tool for developers who want to create WeChat Mini Programs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

WXML Programs

WXML programs can be used to create a variety of interactive and engaging experiences. They are a powerful tool for developers who want to create WeChat Mini Programs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

CREATING A SIMPLE XML PROGRAM USING NETBEANS

AIM:
To write a simple xml program and generate DTD program using
netbeans IDE.

PROCEDURE:

1. Start -> all programs -> netbeans.


2. Select file -> new project -> java web -> web application.
3. Give project name as simplexml -> click on finish.
4. Right click on the project simplexml -> select new -> others.
5. Choose xml -> xml document -> give name as xxml -> finish.
6. Add the following :

<PARTS>
<TITLE>Computer Parts</TITLE>
<PART>
<ITEM>Motherboard</ITEM>
<MANUFACTURER>ASUS</MANUFACTURER>
<MODEL>P3B-F</MODEL>
<COST> 123.00</COST>
</PART>
<PART>
<ITEM>Video Card</ITEM>
<MANUFACTURER>ATI</MANUFACTURER>
<MODEL>All-in-Wonder Pro</MODEL>
<COST> 160.00</COST>
</PART>
</PARTS>
7. Right click on the xml program -> select generate DTD.

OUTPUT:

RESULT:
Thus, the above program was successfully executed and verified.
XML WITH XSL STYLESHEET USING NETBEANS

AIM:
To write a xml program with xsl stylesheet using netbeans.

PROCEDURE:

1. Open the note pad.


2. Write the code for xsl program and give the name as Newxsl.
3. Save it as Newxsl.xsl.
4. Open the another notepad.
5. Write the xml program and in the header file connect the xsl program by
its name.hjgjghkghjghjkh
6. Save the program as New.xml.
7. To run the program, double click on the xml file.

PROGRAM:
Newxsl.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/collection">
<html>
<head>
<title>newstylesheet.xsl</title>
</head>
<h1>!!! MOVIES !!!</h1>

<body>
<table border="3" cellpadding="2">
<tr>
<th>TITLE</th>
<th>YEAR</th>
<th>GENRE</th>
</tr>
<xsl:for-each select=" movie">
<tr>
<td><xsl:value-of select="title"/></td>
<td> <xsl:value-of select="year"/></td>
<td> <xsl:value-of select="genre"/></td></tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

New.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="newxsl.xsl" type="text/xsl"?>
<collection>

<movie>
<title>Two States</title>
<year>2014</year>
<genre>Non-Fiction</genre>
</movie>
<movie>
<title>Harry Potter</title>
<year>2005</year>
<genre>Fiction</genre>
</movie>
<movie>
<title>Iron Man</title>
<year>2009</year>
<genre>Comic</genre>
</movie>
</collection>

OUTPUT:

RESULT:
Thus, the above program for xsl stylesheet has been executed and
verified.
DOMPARSER USING NETBEANS
AIM:
To write a java program to develop domparser using Netbeans.

PROCEDURE:

1. In Netbeans IDE,select file→new project→Java→Java Application→give


the name as Domparser→finish.
2. Right click the project→New→Java class→give the name as
NewClass→give the package name→finish.
3. Right click the project→new→other→XML→XML Documents→give the
name as Dom→next→finish.
4. In the NewClass.java, type the required code.
5. In the Dom.xml, type the required code of xml.
6. After typing the code,run the file NewClass.java
7. The output will be displayed.

PROGRAM:
Domparser.java
import javax.xml.parsers.*;
import java.io.IOException;
import org.w3c.dom.*;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

public class NewClass {


public static void main(String[] args)
{
DocumentBuilderFactory
factory=DocumentBuilderFactory.newInstance();
try
{
DocumentBuilder builder=factory.newDocumentBuilder();
Document doc=builder.parse("Dom.xml");
NodeList personList=doc.getElementsByTagName("person");
for(int i=0;i<personList.getLength();i++)
{
Node p=personList.item(i);
if(p.getNodeType()==Node.ELEMENT_NODE){
Element person=(Element)p;
String id= person.getAttribute("id");
NodeList namelist= person.getChildNodes();
for(int j=0;j<namelist.getLength();j++){
Node n=namelist.item(j);
if(n.getNodeType()==Node.ELEMENT_NODE){
Element name=(Element)n;
System.out.println("person"+id+":"+name.getTagName()+"="+name.getT
extContent());
} } } } }

catch(ParserConfigurationException e)
{ e.printStackTrace(); }
catch(SAXException e)
{ e.printStackTrace(); }
catch(IOException e)
{ e.printStackTrace(); }
}
}
Dom.xml
<?xml version="1.0" encoding="UTF-8"?>
<people><person id="1">
<firstname>Robert</firstname>
<lastname>DowneyJ</lastname>
</person><person id="2">
<firstname>Bradley</firstname>
<lastname>Sara</lastname>
</person><person id="3">
<firstname>Rajiv Gandhi</firstname>
<lastname>J S</lastname>
</person>
</people>

OUTPUT:
run:
person1:firstname=Robert
person1:lastname=DowneyJ
person2:firstname=Bradley
person2:lastname=Sara
person3:firstname=Rajiv Gandhi
person3:lastname=J S
BUILD SUCCESSFUL (total time: 0 seconds)

RESULT:
Thus, the above program for Domparser has been executed and verified.
DEVELOPING WEB APPLICATIONS IN NETBEANS USING JAVA

AIM:
To develop Web application for displaying user details using Netbeans
IDE.

PROCEDURE:
1. Start->All Programs->NETBEANS IDE.
2. Select File->New Project->Java Web->Web Application.

3. Give the project name as SampleWeb select glassfish server and click the
finish button.
4. In SampleWeb ->select source packages right click select new->java class-
>file name as sample handler ->package as org.mypackage.sample->click
on finish.
5. In samplehandler.java declare the variable and constructor and right
click select refactor
->encapsulate filed.

6. Select get and set method and click refactor.


7. Now select index.jsp then select tools->palatte->html/jsp code clips
8. Under plattete manager select html forms->form click and drag after the
h1 tag of index.jsp.
9. Give action as response.jsp and method as get and name as name input
form.

10. Next drag text input give name as name and click ok.in the text input
tag delete value.
11. Drag the button and give label as ok and type as submit then click
on ok.

12. Before input tag type as “enter your name”.

13. Now select SampleWeb project right click->select new->jsp


14. Give the project name as response then click finish.

15. Select tools->palatte->html/jsp code clips then palatte manager will


open.

16. Select jsp->use bean drag and drop it after body tag of response.jsp
17. In use bean give id as mybean and class as
org.mypackage.sample.samplehandler and scope as session.

18. Then select set bean property drag and place give bean name as
mybean and click on ok.In the set bean tag delete the value.
19. now select get bean property and drag inside of h1 tag (i.e after
hello )give bean name as mybean and property name as name.

20. Select SampleWeb from project right click->run


OUTPUT:

21. Enter the name and click ok it brings you the next page.

RESULT:

Thus the web application has been successfully developed using


Netbeans IDE.
DESIGNING GUI USING NETBEANS IDE

AIM:
To design GUI for bank application in java using Netbeans IDE.

PROCEDURE:

1. Start->All Programs->Netbeans IDE.


2. Select File->New Project->Java->Java Application.

3. Give Project name as NewBalance ,uncheck the main class and click finish.
4. Select File->New File->Swing GUI Forms->JFrame form.
5. Give file name newbalance and click ok.

6. Now design the balance page with six labels and two text field and button.
7. Change the variable name textfield1 name as credit amount and
textfield2 as debitamount and label as resultbalance .This is done by
performing right click.
8. Insert menu bar with file and edit.under file add sub menu by dragging
menu item and give name as exit.
9. Add the shortcut for exit by double click on it.give ctrl+q as short cut key.
10. Double click on getbalance button and add the following code.

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)


{
// TODO add your handling code here:
double creditbalance=Double.parseDouble(creditamount.getText());
double debitmoney=Double.parseDouble(debitamount.getText());
double initialbalance=5000.0;
double balancemoney=initialbalance+creditbalance-debitmoney;
resultbalance.setText("RS"+balancemoney);
}
For exit double click and the following code:
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling code here:
System.exit(1);
}
11. This coding can also add by right click on button ->select->events-
>action->action performed.
12. Select NewBalance project->right click->select Run.

13. Give the input for credit amount and debit amount and click on
getblance button and also check for exit with shortcut.

RESULT:
Thus the GUI design for bank application has been successfully
deployed.
EJB COMPONENT FOR FINDING SQUARE OF A NUMBER

AIM:
To develop EJB component for finding square of a nember using Netbeans
IDE.

PROCEDURE:

1. Start->All Programs->Netbeans IDE.


2. Select File menu->New Project->Java->Java Class Library

3. Give the project name as SampleEJB and click the finish button.
4. Select file menu->New Project->Java EE->Enterprise Application.

5. Give the project name as SampleEJ select glassfish vs as server and click
the finish button.
6. Select SampleEJ-ejb right click and select new sessionbean.

7. Give the EJB name as EJBSession and select session type as stateless give
the package as in and select interface as remote and click the finish
button.
8. Right click on EJBSession select insert code->select add business method.
9. Under Add business method give name as get and return type as int and
click add button give the variable name and the data type and local
interface as remote.
10. Following code will displayed:

11. Select SampleEJ-war right click->select new->servlet.


12. Give the class name as SquareServlet and click next.

13. Select add information and click finish.


14. Now right click inside the program select Insert code->call
enterprise bean->EJBSession-ejb->EJBSession and select interface as
remote click on ok.
15. The following will added:
16. Change the request.getContextPath() as EJBSession.get(10).

17. Right click on SampleEJB select Run.


OUTPUT:

RESULT:

Thus the EJB component for finding square has been successfully
executed using Netbeans IDE.
EJB COMPONENTS FOR FINDING POWER VALUE

AIM:
To write a program for EJB components for finding power value.

PROCEDURE:
1. Start->All Programs->NetbeansIDE
2. Select File Menu->New Project->JavaEE->Enterprise application.
3. Give the project name as powerservice select glassfish vs server and click
the finish button.
4. Select the powerservice-ejb right click and select new session.
5. Give the EJB name as powersessionbean and select sessiontype as
stateless and interface as remote give the package name as mypack and
click the finish.
6. Select powersessionbean class insert the business method find power.
7. Right click select insert code option->add business method give the name
as findpower return type as int.
8. Select powerservice-war right click new->servlet.give name as
powerservlet and select add the information method .
9. Now right click inside the program select Insert code->call enterprise
bean->EJBSession-ejb->EJBSession and select interface as remote click on
ok.
10. Select powerservice-war right click new->JSP.give name as
index.jsp.and the form tag and two text field and button using palatte.
11. Deploy and run the project.
PROGRAM:
POWERSESSIONBEAN.JAVA
package mypack;
import javax.ejb.Stateless;

@Stateless
public class powersessionbean implements powersessionbeanRemote {
public int findpower(int x, int y) {
int result=1;
for(int i=0;i<y;i++)
{
result=result*x;
}
return result;
}
POWERSERVLET.JAVA:
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import powerj.powersessionjRemote;
public class powerservletj extends HttpServlet {
@EJB
private powersessionjRemote powersessionj;
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();

int a,b;
a= Integer.parseInt(request.getParameter("xval"));
b=Integer.parseInt(request.getParameter("yval"));
try {
// TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet powerservletj</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Answer: "+a+"power"+b+" =
"+powersessionj.findpower(a,b)+"</h1>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on
the + sign on the left to edit the code.">
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold> }

INDEX.JSP:

<%@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>Finding power value!!!</h1>
<form action="powerservletj">
Enter the value: <input type="text" name="xval" /><br>
Enter the power: <input type="text" name="yval" /><br><br>
<input type="submit" value="Answer" name="cal" />
</form>
</body>
</html>
OUTPUT:

RESULT:
Thus, the above program for finding power value was successfully
executed and verified.
DEVELOPING SIMPLE WEB APPLICATIONS IN NETBEANS USING JAVA

AIM:
To develop simple web application for displaying user details using
Netbeans IDE.

PROCEDURE:
1. Start->All Programs->NETBEANS IDE.
2. Select File->New Project->Java Web->Web Application.
3. Give the project name as asone select glassfish server and click the finish
button.
4. In SampleWeb ->select source packages right click select new->java class-
>file name as ashandler ->package as org.mypackage.sample->click on
finish.
5. In ashandler.java declare the variable and constructor and right click
select refactor
a. ->encapsulate filed.
6. Select get and set method and click refactor.

i.

7. Now select index.jsp then select tools->palatte->html/jsp code clips


8. Under plattete manager select html forms->form click and drag after the
h1 tag of index.jsp.
9. Give action as response.jsp and method as get and name as name input
form.
10. Next drag text input give name as name and click ok.in the text input
tag delete value.
11. Drag the button and give label as ok and type as submit then click
on ok.

12.
13. Before input tag type as “Enter your name”, “Enter your
department”, “Enter your college name”.
14. Now select asone project right click->select new->jsp. Give the
project name as response then click finish. Select tools->palatte-
>html/jsp code clips then palatte manager will open.
15. Select jsp->use bean drag and drop it after body tag of response.jsp
16. In use bean give id as mybean and class as
org.mypackage.sample.samplehandler and scope as session.
17. Then select set bean property drag and place give bean name as
mybean and click on ok.In the set bean tag delete the value.
18. Now select get bean property and drag inside of h1 tag (i.e after
hello )give bean name as mybean and property name as name.
19.

20. Select SampleWeb from project right click->run


OUTPUT:

21. Enter the name and click ok it brings you the next page.

RESULT:

Thus the web application has been successfully developed using


Netbeans IDE.
DESIGNING GUI FOR TEMPERATURE CONVERSION USING NETBEANS IDE

AIM:
To design GUI for temperature conversion application in java using
Netbeans IDE.

PROCEDURE:

1. Start->All Programs->Netbeans IDE.


2. Select File->New Project->Java->Java Application.
3. Give Project name as temperature ,uncheck the main class and click
finish.
4. Select File->New File->Swing GUI Forms->JFrame form.
5. Give file name temp and click ok.
6. Now design the balance page with four labels and one text field and two
buttons.
7. Change the variable name textfield1 name as temp and last label as
result.This is done by performing right click.
8. Insert menu bar with file and edit under file add sub menu by dragging
menu item and give name as exit.
9. Add the shortcut for exit by double click on it give ctrl+backspace as short
cut key.
10. Double click on C to F button and add the following code.

a. private void jButton1ActionPerformed(java.awt.event.ActionEvent


evt) {
i. // TODO add your handling code here:
ii. double tempp=Double.parseDouble(temp.getText());
iii. double res=9*tempp/5+32;
b. result.setText(""+res);
c. }
d. Double click on F to C button and add the following code.
e. private void jButton2ActionPerformed(java.awt.event.ActionEvent
evt) {
i. // TODO add your handling code here:
ii. double tempp=Double.parseDouble(temp.getText());
iii. double res =tempp-32*5/9;
iv. result.setText(""+res);
f. }
g. For exit double click and the following code:
h. private void
jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
i. // TODO add your handling code here:
ii. System.exit(1);
i. }
11. This coding can also add by right click on button ->select->events-
>action->action performed.
12. OUTPUT:

13. Select NewBalance project->right click->select Run.

14.

15. Give the input for Enter the temperature on C to F and F to C buttons as
shown to convert temperature and also check for exit with shortcut.

16. RESULT:
i. Thus the GUI design for temperature conversion application
has been successfully deployed.
EJB COMPONENT FOR SIMPLE AND COMPOUND INTEREST

AIM:
To develop EJB component for finding simple and compound interest
using Netbeans IDE.

PROCEDURE:

1. Start->All Programs->Netbeans IDE.


2. Select File menu->New Project->Java->Java Class Library
3. Give the project name as interest and click the finish button.
4. Select file menu->New Project->Java EE->Enterprise Application.
5. Give the project name as interestejb select glassfish vs as server and click
the finish button.
6. Select interestejb-ejb right click and select new sessionbean.
7. Give the EJB name as interestSession and select session type as stateless
give the package as in and select interface as remote and click the finish
button.
8. Right click on interestSession select insert code->select add business
method.
9. Under Add business method give name as simple and return type as float
and click add button give the variable name and the data type and local
interface as remote. Similarly for compound method.
10. Following code will displayed:
11.
12. Select interestejb-war right click->select new->servlet.
13. Give the class name as simpleservlet and click next.
14. Select add information and click finish.

15. Now right click inside the program select Insert code->call
enterprise bean->interestSession-ejb->InterestSession and select
interface as remote click on ok.

16. The following will added:

a.
17. Change the request.getContextPath() as
ejbsession.simple(30000,3.0f,0.35f) for simple interest and copy the
same line, paste it next to it and where change the
ejbsession.simple(30000,3.0f,0.35f) as
ejbsession.compound(5000,2.0f,0.30f) for compound interest as shown
above.

18. Right click on SampleEJB select Run.

OUTPUT:

RESULT:

Thus the EJB component for finding simple interest and compound
interest has been successfully executed using Netbeans IDE.
EJB COMPONENT FOR ORDER PLACING

AIM:
To develop EJB component for order placing using Netbeans IDE.

PROCEDURE:

1. Start->All Programs->Netbeans IDE.


2. Select File menu->New Project->Java->Java Class Library
3. Give the project name as order and click the finish button.
4. Select file menu->New Project->Java EE->Enterprise Application.
5. Give the project name as orderejb select glassfish vs as server and click
the finish button.
6. Select orderejb-ejb right click and select new sessionbean.
7. Give the EJB name as ordersession and select session type as stateless
give the package as in and select interface as remote and click the finish
button.
8. Right click on ordersession select insert code->select add business
method.
9. Under Add business method give name as orderplace and return type as
float and click add button give the variable name and the data type and
local interface as remote.
10. Following code will displayed:
11. Select orderejb-war right click->select new->servlet.
Give the class name as orderservlet and click next.
12. Select add information and click finish.
13. Now right click inside the program select Insert code->call
enterprise bean->ordersession-ejb->ordersession and select interface as
remote click on ok.

14. The following will added:

15. Change the request.getContextPath() as


orderplace(5,20,4,6.50f,15,40.75f). And if needed add statements that is
to be displayed additionally in the output as shown.

16. Right click on orderejb select Run.


OUTPUT:

RESULT:

Thus the EJB component for placing order and finding total cost has been
successfully executed using Netbeans IDE.
EJB COMPONENT FOR PAYMENT PROCESSING

AIM:
To develop EJB component for payment processing i.e, calculating gross
salary of an employee using Netbeans IDE.

PROCEDURE:

1. Start->All Programs->Netbeans IDE.


2. Select File menu->New Project->Java->Java Class Library
3. Give the project name as salaryjj and click the finish button.
4. Select file menu->New Project->Java EE->Enterprise Application.
5. Give the project name as salaryjj2 select glassfish vs as server and click
the finish button.
6. Select salaryjj2-ejb right click and select new sessionbean.
7. Give the EJB name as saljjsession and select session type as stateless give
the package as salaryjjpack and select interface as remote and click the
finish button.
8. Right click on saljjsession select insert code->select add business method.
9. Under Add business method give name as calsal and return type as float
and click add button give the variable name and the data type and local
interface as remote.
10. Following code will displayed:
11. Select salaryjj2-war right click->select new->servlet.
12. Give the class name as salaryjjservlet and click next.
13. Select add information and click finish.

14. Now right click inside the program select Insert code->call
enterprise bean->saljjsession-ejb->saljjsession and select interface as
remote click on ok.

15. The following will added:


16. Change the request.getContextPath() as
saljjsession.calsal(30333630,”Jaya”,50000). And if needed add
statements that is to be displayed additionally in the output as shown.

17. Right click on salaryjj2 select Run.


OUTPUT:

RESULT:

Thus the EJB component for finding payment processing has been
successfully executed using Netbeans IDE.
CREATING A WEB SERVICES FOR ARITHMETIC OPERATION

AIM:
To create a web services for arithmetic operation.

PROCEDURE:

1. Start -> All programs -> Netbeans.


2. Select file -> New project -> Choose JavaWeb -> Web application.
3. Give project name as arithj-> click on Finish.
4. Right click on the project -> Select new -> Web service -> Give web
service name -> Give package name -> click on finish.
5. Right click on class -> select insert code -> select add web service
operation.
6. Provide method name -> provide return type -> give parameters with
datatype -> finish.
7. Following code will be displayed:

package mypackj;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class arithwebj {
@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);
}
@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);
}
@WebMethod(operationName = "mul")
public int mul(@WebParam(name = "a")
int a, @WebParam(name = "b")
int b) {
//TODO write your implementation code here:
return (a*b);
}
@WebMethod(operationName = "div")
public float div(@WebParam(name = "a")
intt a, @WebParam(name = "b")
int b) {
//TODO write your implementation code here:
return (a/b);
}
}

8. Right click on the project -> deploy the project.


9. After deployed -> Right click on the webservice (under the project) ->
click on test web service.
10. Run the project.
OUTPUT:
RESULT:
Thus, the above program was successfully executed and verified.
CREATING A WEB SERVICE AND CALLING A WEB SERVICE IN ASP.NET

AIM:
To create a web service and calling a web service for a addition function
using visual studio.

PROCEDURE:

1. Start -> All programs -> Visual studio.

2. Select file -> new -> website -> select visual c# and empty website.

3. Give the project name as additionservice.

4. Right click on the project additionservice -> choose add new item -> select

webservices
5. Create a addition function and add the following code:
6. Right click on the project additionservice -> choose add new item -> select

webform
7. Choose split -> select toolbox -> drag and drop the textbox, button and label

for result.
8. Add the following code:
9. Double click on the button and add the coding as follows:

10. Right click on the project additionservice -> select build website

11. Right click on the project additionservice -> select view in browser.

OUTPUT:
RESULT:
Thus the above program for creating a web service of addition using
asp.net was successfully executed and verified.
CREATING A WEB SERVICES FOR STRING OPERATION

AIM:
To create a web services application for String operation.

PROCEDURE:

1. Start -> All programs -> Netbeans.


2. Select file -> New project -> Choose JavaWeb -> Web application.
3. Give project name as stringj-> click on Finish.
4. Right click on the project -> Select new -> Web service -> Give web
service name ->
Give package name -> click on finish.
5. Right click on class -> select insert code -> select add web service
operation.
6. Provide method name -> provide return type -> give parameters with
datatype -> finish.
7. Following code will be displayed:
package mypackj;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class stringoperationj {
@WebMethod(operationName = "names")
public String names(@WebParam(name = "name1")
String name1, @WebParam(name = "name2")
String name2) {
//TODO write your implementation code here:
return (name1+name2);
} }

8. Right click on the project -> deploy the project.


9. After deployed -> Right click on the webservice (which is under the
project) -> click on test web service.
10. Run the project.

OUTPUT:

stringjservice
RESULT:
Thus, the above program was successfully executed and verified.
JAXB BINDING PROGRAM

AIM:
To generate a java program by xml program using JAXB binding.

PROCEDURE:

1. All programs ->Netbeans ->new project.


2. Select java -> java application -> give project name as jaax -> provide
package name as org.pack->click on finish.
3. Select file -> xml -> xml schema-> give the name as jaax1-> Finish.
4. Choose the project -> select the jaax1.xsl.
5. Add the following code:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/jaax1"
xmlns:tns="http://xml.netbeans.org/schema/jaax1"
elementFormDefault="qualified">

<xsd:element name="shiporder">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="orderperson" type="xsd:string"/>
<xsd:element name="shipto">
<xsd:complexType>

<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>

<xsd:element name="Address" type="xsd:string"/>


<xsd:element name="City" type="xsd:string"/>

<xsd:element name="Country" type="xsd:string"/>


</xsd:sequence> </xsd:complexType></xsd:element>
<xsd:element name="item" maxOccurs="unbounded">
<xsd:complexType>

<xsd:sequence>
<xsd:element name="productid" type="xsd:positiveInteger"/>
<xsd:element name="note" type="xsd:string" minOccurs="0"/>
<xsd:element name="quantity" type="xsd:positiveInteger" />
<xsd:element name="price" type="xsd:decimal" />

</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="orderid" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>

6. Right click on the project jaax -> new file -> select others -> xml -> jaxb
binding.
7. Give the name as jaax2-> Browse for schema file jaax1-> click on finish.

8. On the project -> Right click on the JAXB bindings -> select regenerate
java code.

9. Choose generated source code -> open the package org.pack -> Open
Shiporder.java.
OUTPUT:

RESULT:
Thus, the above program was successfully execute and verified.
CREATION OF WEB SERVICE CLIENT
AIM:
To create a web service for adding few numbers using NetBeans and write
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.ewsdlurl
11. Drag and drop the web service reference to the source code
window.
12. Then pass the appropriate parameters to the web service client and
invoke the web service.
STEPS TO CREATE CLIENT SIDE PROJECT:

1. Create the new project as above and give the name as addclient.

2. addclient project will be created right click it and choose the following.
3. Then browse and choose the addwebwsdl file

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

Index.jsp source code


<%@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>
<form name="" action="actionn.jsp" method="post">
Enter 1st No:<input name="fst" type="text" /><br/>
Enter 2nd No:<input name="snd" type="text" /><br/>
<input name="ok" type="submit" value="Add" />
</form> </body> </html>

5. Then create an action.jsp as follows.

Right click web page in addclient and choose new->jsp


Name: actionn
Click finish

6. Click on the actionn.jsp page then right click in it and choose web service
client reference ->call web service
7. The invoke the add service.

8. Add the following code in the action.jsp

<%@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>
<%
String a1=request.getParameter("fst");
String b1=request.getParameter("snd");
intaa=Integer.parseInt(a1);
int bb=Integer.parseInt(b1);
%>
<%-- start web service invocation --%><hr/>
<%
try {
org.AddwebService service = new org.AddwebService();
org.Addweb port = service.getAddwebPort();
// TODO initialize WS operation arguments here
int a = aa;
int b = bb;
// 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:
9. Finally undeploy and deploy the addclient and run it.

RESULT:
Thus, the above program was successfully executed and verified.
CREATING A LOGIN PAGE USING JAVA SWING

AIM:
To create a login page using JAVA Swing in the Netbeans IDE.

PROCEDURE:
1. File→new project→java→java application→give the name of the project
and the package name→finish.
2. Right click on the project →new→JFrame form→give the frame name
→click finish.
3. From the toolbox drag and drop two labels , two textboxes and one button.

4. Right click on the text box→select Change Variable Name→set textbox1 as


username→and set textbox2 as password.
5. Double click on the button and write the following code:
6. Database Creation:
i. Start→all programs→oracle database 10g→go to database
homepage→give the username and the password.
ii. Click on the from the object browser and select create
table→give the table name→create two columns username and
password and select varchar as datatype.
iii. Click next→next→ at last click “create”.
iv. Click on Data→ select insert row and give the username and
password.

7. Database Connection:
i. Select service explorer→Database→right click→new
connection→select drivers: Oracle Thin→select Add
button→select OJDBC11.JAR file.
ii. Give the host name as localhost; port : 1521; service ID : XE;
username : System; Password : Tiger→click on Test
Connection→next→next→finish.
8. How to run :
Right click on the JFrame form(login)→select “run file”.
OUTPUT:

RESULT:
Thus, the above program was successfully executed and verified.
CREATE A WEB SERVICE USING ASP.NET
AIM:
To create a web service for addition function using ASP.NET.

PROCEDURE:

1. Open visual studio 2010->new->website->visual c#->choose empty asp


.net and choose a name for your project. In my project my example name
is calculator.

2. Right click on the project select add->new item->web service and give
name for web service as firstwebservice->add.
3. Add the web method for calculator operation as shown in the figure.
4. Right click on the project select view in browser.
5. Click on firstwebservice.asmx.

6. Click the add link.


7. Give the input value and press invoke button.

8. Select new project->windows->windows application->firstform.


9. Create two numbericupdownbutton, one label and four button from
toolbox.
10. Now right click on firstform->add service reference, press discover
select firstwebservice and give service reference as firstreference->ok

11. Your service reference will be added to your firstform.double click


on it.
Check the yourwebmethod are added in your reference.

12. Now double click on the button and add the following code.(include
the header file using firstform.firstreference.)
13. Right click on the solution->properties->set start up web sites as
firstform.
OUTPUT:

14. Now click the build symbol. the following will get as ouput.

Result:
Thus the creation a web service for addition function program has been
executed and verified successfully
CREATING EMPLOYEE DETAILS USING JAVA SWING
AIM:
To create employee details using JAVA Swing in the Netbeans IDE.

PROCEDURE:
1. File→new project→java→java application→give the name of the project
and the package name→finish.
2. Right click on the project →new→JFrame form→give the frame name
→click finish.
3. From the toolbox drag and drop seven labels , six textboxes and one
button.

a.

4. Double click on the button and write the following code:


5.

6.

7. Database Creation:
8. Start→all programs→oracle database 10g→go to database
homepage→give the username and the password.
9. Click on the from the object browser and select create table→give the
table name→create the requiredcolumns andselect the required
datatype.
10. Click next→next→ at last click “create”.
11. Database Connection:
12. Select service explorer→Database→right click→new
connection→select drivers: Oracle Thin→select Add button→select
OJDBC11.JAR file.
13. Give the host name as localhost; port : 1521; service ID : XE;
username : System; Password : Tiger→click on Test
Connection→next→next→finish.
14. How to run :

a. Right click on the JFrame form(employ)→select “run file”.

OUTPUT:
Before inserting:
After inserting:

RESULT:
Thus, the above program was successfully executed and verified.
CREATION OF A BPEL MODULE AND A COMPOSITE APPLICATION
AIM:
To Create a SOA project with BPEL Module to compose a web service.

STEPS TO CREATE A BPEL MODULE:

Creating a new BPEL Module Project


The following sections use the Synchronous sample project, and provide
step-by-step directions for creating a simple BPEL module project, using the
Synchronous sample project.
To Create a BPEL Module Project
1. In the NetBeans IDE, choose File > New Project.

The New Projects wizard appears.


Under Categories, select Service Oriented Architecture.
2. Under Projects, select BPEL Moduleand click Next.

3. In the Name and Location page, enter the project name (for this example
HelloWorld) and specify the project location or accept the defaults.
4. Click Finish.
The Projects window now contains a project node for the BPEL Module project.

Creating a BPEL Process Using the BPEL Designer


Now that you have created your XML Schema and WSDL Document, you can
create your BPEL process.
To Create the BPEL Process
1. In the Projects window, expand your BPEL module project node, right-
click the Process Files node, and choose New -> BPEL Process.
The New BPEL Process dialog box appears.
2. Enter a name for the process file name (HelloWorldProcess for this
example), and click Finish.
The new BPEL file opens in the Design view of the BPEL Designer.
If the Palette and Properties windows are not displayed in your current view,
click Windows -> Reset Windows on the NetBeans menu.

3. Add a partner link to the BPEL Process.


a. In the Projects window, expand your project's Process Files node
and select the .wsdl file (Synchronous.wsdl for this example).
b. Drag the WSDL file from the Projects window to the left side of the
Design view canvas.
The IDE provides visual prompts to show you where you can drop the selection.
The BPEL Editor adds a partner link to the canvas.

4. Add a Receive activity to the BPEL Process.


a. From the Web Service section of the Palette window, select the
Receive activity.
b. Drag the Receive activity to the HelloWorldProcess process box in
the Design view canvas, between the Process Start and the Process
End activities.
The Receive1 activity is added to the process box.
c. Click the Receive1 activity's Edit icon.
The Receive1 Property Editor appears.
d. On the Main tab, change the value in the Name field to start.
e. From the Partner Link drop-down list, choose PartnerLink1.
The IDE populates the Operation field with NewWSDLOperation.
f. Click the Create button next to the Input Variable Field.
The New Input Variable dialog box appears.
g. Click OK to accept the default values.
h. Click OK to close the Receive1 Property Editor.
The Design view displays the new connection between PartnerLink1 and the
Start activity in the process box.

5. Add a Reply activity to the BPEL Process.


a. Select the Reply activity in the Web Service section of the Palette.
Drag and drop the Reply to the prompt between the Start activity
and the Process End activity in the process box on the design view
canvas.
A Reply1 activity is added to the design view canvas.
b. Click the Reply1 activity's Edit icon.
The Reply1 Property Editor appears.
c. On the Main tab, change the value in the Name field to End.
d. From the Partner Link drop-down list, choose PartnerLink1.
The IDE populates the Operation field with NewWSDLOperation.
e. To create anew output variable, make sure that Normal Response is
selected, and click the Create button next to the Input Variable
Field.
The New Input Variable dialog box appears. Click OK to accept the default
values.
f. Click OK to close the Reply1 Property Editor.
The Design view displays the new connection between the End activity in the
process box and PartnerLink1.

6. Add a Assign activity to the BPEL Process.


a. Select the Assign activity in the Basic Activities section of the
Palette. Drag and drop the Assign to the prompt between the Start
activity and the End activity in the process box on the design view
canvas.
The Assign1 activity is added to the design view canvas.
b. Select the Assign1 activity and click the Mapper button on the
editors toolbar.
The BPEL Mapper appears.
c. Map the paramA node under Variables ->NewWSDLOperationIn -
>inputType in the Output pane of the BPEL Mapper, to the paramA
node under Variables ->NewWSDLOperationOut ->resultType in the
Input pane of the Mapper. To do this, select theparamA node under
Variables ->NewWSDLOperationIn ->inputType in the Output pane,
and drag your cursor to the paramA node under Variables -
>NewWSDLOperationOut ->resultType in the Input pane.
This assignment copies the input statement into the output.

7. To save your changes click the Save All icon in the IDE menu bar.
Creating a Composite Application Project
A BPEL Module project is not directly deployable. You must first add a BPEL
Module project, as a JBI module, to a Composite Application project. You can
then deploy the Composite Application project. Deploying the project makes
the service assembly available to the application server and enables its service
units to run.
To Create a New Composite Application Project
1. Choose File > New Project (Ctrl-Shift-N).
2. In the Categories list choose Service Oriented Architecture, in the Projects
list choose Composite Application, and click Next.
3. In the Name and Location page, change the project name to
HelloWorldApplication, and specify the location of project files.
4. To set the new Composite Application the main project as main, leave the
Set as Main Project checkbox selected, and click Finish.
5. To add the BPEL Module as a JBI module to the Composite Application
project, right-click the new Composite Application and choose Add JBI
Module.
The Select Project dialog box opens.
6. Select the HelloWorld project you created earlier and click Add Project
JAR Files.
The Select Project dialog box closes and the HelloWorld.jar file is added to the
JBI Modules node of the HelloWorldApplication Composite Application
Building and Deploying the Composite Application Project
Building a project compiles the BPEL source file and packages the BPEL file and
web service artifacts, including WSDL and XSD files, into a JAR archive.
Deploying the project compiles the files in the Composite Application project,
packages the compiled BPEL and related web service artifacts (including WSDL
and XSD files) into an archive, and deploys them to the Application Server.
To Build and Deploy the Composite Application Project
1. Right-click the Composite Application project's node, and choose Build.
When the build is complete the Output window reports Build Successful. If the
Output window is not visible, choose Window -> Output -> Output.
2. Right-click the Composite Application project's node, and choose Deploy.
3. Deployment has succeeded when you see a Build successful message in
the GlassFish tab of the Output window.
4. Open the Services window and expand Servers ->GlassFish V2 -> JBI ->
Service Assemblies to see your new deployed Service Assembly.
If you do not see the deployed project, right-click the Service Assemblies node
and choose Refresh.
Testing the Composite Application
You can test your Composite Application project by adding test cases, binding
to the operation, supplying input, and then using the tester.
Test the HelloWorldApplication Composite Application Project
1. In the Projects window, expand the HelloWorldApplication project node,
right-click the Test node, and choose New Test Case.
The New Test Case wizard opens.
2. Accept the default test case name, TestCase1, and click Next.
3. From the Select the WSDL Document page, expand the HelloWorld - Proecss
Files node, select Synchronous.wsdl, and click Next.
4. From the Select the Operation to Test page, select the Operation1 and click
Finish.
A new TestCase1 node is added under the project's Test node in the Projects
window, containing two subnodes, Input and Output.
The Source Editor appears containing the Input file, Input.xml
Note –
If the Source Editor does not contain a tab for Input.xml, double-click the Input
node in the Projects window to open the file.
5. From the Input.xml tab of the Source Editor, do the following:
a. Locate the line:

<syn:paramA>?string?<syn:paramA>

b. Replace ?string? with Hello World, so that the line appears as follows:

<syn:paramA>Hello World<syn:paramA>

c. From the NetBeans IDE menu bar, click Save All.

6. In the Projects window, double-click the Output node under Test ->
TestCase1.
Output.xml is opened in the Source Editor. Initially, Output.xml is empty until
the first test run populates the file.
7. In the Projects window, right-click the TestCase1 node and choose Run from
the pop-up menu.
When the Overwrite Empty Output dialog box appears, click Yes to accept new
output. The first test run populates the Output.xml file displayed in the Source
Editor.
The test compares the output to the contents of the output file. Because the first
run of the test has nothing to compare itself to, the first test fails. Subsequent
test runs will compare their output with the contents of Output.xml and should
succeed.
8. Run the test again.
The test case is compared to the current output file and succeeds.

RESULT:
Thus, the above program for creating a bpel module and a composite
application was successfully executed and verified.

You might also like