Make a web service program which can persists the records of a student in the exam table.It should use SOAP Request and SOAP Response.
SolutionTo solve the preceding problem, following tasks have to be performed:
This is a small database software bundled with Netbeans in glassfish server.It is easy to create a database, create a table, make the queries
over it.User can connect easily the enterprise program,web service program and web program with derby database software.

Figure 1

Figure 2

Figure 3

Figure. 4
Creating Web Service project
Figure 5

Figure 6
––
Figure. 7

Figure. 8
It creates a full web service class as shown below
package pack1;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService()
public class stud {
@WebMethod(operationName = "exam")
public String exam(@WebParam(name = "roll")
int roll, @WebParam(name = "name")
String name) {
//TODO write your implementation code here:
return null;
}
}
Below in Figure. 9.

Figure. 9

Figure. 10

Figure. 11
package pack1;
import java.sql.Connection;
import java.sql.PreparedStatement;
import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.sql.DataSource;
@WebService()
public class stud {
@Resource(name = "data1")
private DataSource data1;
@WebMethod(operationName = "exam")
public String exam(@WebParam(name = "roll")
int roll, @WebParam(name = "name")String name) {
String status="record not inserted";
try {
Connection con=data1.getConnection();
PreparedStatement ps=con.prepareStatement("INSERT INTO stud VALUES(?,?)");
ps.setInt(1,roll);
ps.setString(2,name);
int i=ps.executeUpdate();
if(i!=0) {
status="record inserted";
}
}
catch(Exception e){
System.out.println("error in strong data"+e);
}
return status;
}
}

Figure. 12

Figure 13

Figure. 14
As shown below in Figure 15.

Figure 15

Figure 16

Figure 17
Client Web Service
Figure. 18

Figure 19

Figure. 20
Client.jsp

Figure. 21

Figure. 22
As shown below in Figure. 23.

Figure. 23
Running The Client file As shown below in Figure. 24.

Figure. 24
Aas shown below in Figure. 25
Figure. 25

Figure. 26
|
Recommend the tutorial |

Ask Questions? Discuss: JAX-RPC Advance Concepts View All Comments
Post your Comment