Application Using JAX-RPC

Project Requirement Make a Netbeans Web Project.In it develop a Web Service application using the JAX-RPC concept.

Application Using JAX-RPC

Application Using JAX-RPC

 

   

Project Requirement Make a Netbeans Web Project.In it develop a Web Service application using the JAX-RPC concept.The Web Service should have operation for interest calculation.Overall develop a Client application for the Web Service.

Solution

  • Develop web project
  • In it create an interface using JAX-RPC
  • Create a web service to implement above interface
  • Build the project.
  • Deploy the project.
  • Test the web service.
  • Develop a Web Client

Create a web project

  • Take a new Project
  • Select Web Application as given below in Figuer1.

Application Using JAX-RPC

  Figuer. 1

  • Give the name of the Project as Jax-RPC as shown in given below

   in Figuer.2 

  • Click on Next

Application Using JAX-RPC

     Figuer 2

  • Select the Server name as GlassFish
  • Click on Next button. As shown below in Figuer 3.
  • Click on Finish  Button .

Application Using JAX-RPC

   Figuer 3
Create an interface

  • Make a Jax-RPC  interface 
  • Right Click on the Project.
  • Select java->java interface
  • Click on the next as shown in Figuer 4 given below

Application Using JAX-RPC

Figuer. 4

  • In the given wizard give the name of the interface
  • Type JAX1 in class name.
  • Click on the Next Button as shown in Figuer 5 given below

Application Using JAX-RPC
   
     Figuer 5

  • Click on the Finish Button as shown in Figuer 5
  • It generates a interface named JAX1
  • Add an operation name interest in it.
  • Also add @WebService  and @SOAPBinding annotation

package pack1;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

/**
 *
 * @author roseindia
 */
@WebService
@SOAPBinding(style=SOAPBinding.Style.RPC)

public interface JAX1 {

  public int interest(int amount,int time,int rate);
}

  • After Creating Inteface now make a web service program
  • Right Click and select NewàWeb Service as given below in Figuer 6

Application Using JAX-RPC

    Figuer 6

  • Give the name of the Web Sevice as  JAXImpl
  • Give the package name as pack1
  • Click on The Next button as shown in Figuer 7 below

Application Using JAX-RPC
      
     Figuer. 7

  • Click on Finish
  • It will generates the Web Service in design view
  • Click on the source view
  • In it  implements the interface JAX1 as shown below

package pack1;
import javax.jws.WebService;

@WebService(endpointInterface="JAX1")

public class JAXImpl implements JAX1{

  public int interest(int amount, int time, int rate) {

  return ((amount*time*rate)/100);

  }  
}

  • Now build the project
  • After building, deploy it on the server as shown below in Figuer 8.

Application Using JAX-RPC

Now we can test our Web Service
Right Click  on the Web Service JaxImpl
Select Test Web Service operation as shown below in Figuer. 8 0

Application Using JAX-RPC

     Figuer 8

  • It will open the browser with the url

  http://localhost:8080/Jax-RPC/JAXImplService?Tester 1

  • Give the values in three text boxes for amount, rate and time respectively
  • Click  on  interest Button as shown in below in Figuer 9.

Application Using JAX-RPC

 

Application Using JAX-RPC 2

 

Application Using JAX-RPC

Application Using JAX-RPC 3

Application Using JAX-RPC

Application Using JAX-RPC

Application Using JAX-RPC 4

Application Using JAX-RPC

<%
  try {
  pack1.JAXImplService service = new pack1.JAXImplService();
  pack1.JAX1 port = service.getJAXImplPort();
   // TODO initialize WS operation arguments here
  int arg0 = 2000;
  int arg1 = 10;
  int arg2 = 4;
  // TODO process result here
  int result = port.interest(arg0, arg1, arg2);
  out.println("Interset is  = "+result);
  } catch (Exception ex) {
  // TODO handle custom exceptions here
  }
  %>
Application Using JAX-RPC

Application Using JAX-RPC 5

Download Code