|Home > Documentation > Reference > Samples > Sample applications > jaxws-calculator - Simple Web Service with JAX-WS|
|inventory - Simple Database Access Application||Sample applications||jms-mdb - JMS and MDB Sample Application|
The sample application referred in this article is a simple calculator which performs addition of two integers. The web service is exposed as a Servlet in the Geronimo application server.
Two clients are provided: a jsp page and a non-javaee client.
The Calculator interface defines the Service Endpoint Interface (SEI) for the Web Service.
The CalculatorService class implements the Web Service business logic. It implements all the methods defined in the SEI. The class does not need to implement the Calculator interface but must reference it through the @WebService.endpointInterface annotation. This class will be exposed as a Servlet through web.xml file even though it does not extend the javax.servlet.Servlet class.
The context variable marked with the @Resource annotation will be injected at runtime. The WebServiceContext can be used to obtain the message context and security information relative to the call.
The web.xml descriptor is used to deploy the Web Service.
The geronimo plan has no information for the web service but does specify more information for the service-ref for the jsp client. For tomcat, the plan can be located after building the project in jaxws-calculator/jaxws-calculator-tomcat/target/resources/META-INF/plan.xml. For Jetty, the plan can be located after building the project in jaxws-calculator/jaxws-calculator-jetty/target/resources/META-INF/plan.xml.
The following WSDL file describes the Web Service:
The add.jsp is a basic client for the CalculatorService Web Service.
The add.jsp looks up a Web Service reference in the JNDI tree. The Web Service reference must first be added the web.xml file.
To test this sample service using the add.jsp (http://localhost:8080/jaxws-calculator/) to invoke the Web Service. Once the JSP page loads type in two values to add and press the Add button. The result of the addition should show up below. For example: