Hi all,

I am new to this forum.

I am a beginner to use java web-service programming. I am using netbeans. After creating a web service named CalculatorWS following the steps in Getting Started with JAX-WS Web Services - NetBeans IDE Tutorial, I used the steps shown in Developing JAX-WS Web Service Clients - NetBeans IDE Tutorial to create a client service that consumes my CalculatorWS web service. I modified the steps to match my objective of adding numbers rather than spell check. While every thing was ok as I go through the steps to create my client service, when I run my client service the servlet does not run (or I would say, I do not see the effect of the servlet) but the jsp is running. Eventually it gives the error that says:

HTTP Status 404 -


type Status report


descriptionThe requested resource () is not available.


GlassFish Server Open Source Edition 3.1.2

I do not understand why this is happening, and I am looking for help.

Below I am giving you a more detailed information about my codes:

(1) My webservice: CalculatorWS.java

package org.me.calculator;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;

@WebService(serviceName = "CalculatorWS")
public class CalculatorWS {

public int add(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
int k = i + j;
return k;


(2) My client service: CalculatorServlet.java

package clientservlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.WebServiceRef;
import org.me.calculator.CalculatorWS_Service;

@WebServlet(name = "CalculatorServlet", urlPatterns = {"/CalculatorServlet"})
public class CalculatorServlet extends HttpServlet {
@WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/CalculatorWS/CalculatorWS.wsdl")
private CalculatorWS_Service service;

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

PrintWriter out = response.getWriter();
try {
out.println("<title>Servlet CalculatorServlet</title>");
out.println("<h1>Servlet CalculatorServlet at " + request.getContextPath() + "</h1>");

try {

//Get the TextArea from the JSP page
String TextArea1 = request.getParameter("TextArea1");

java.lang.String bodyText = TextArea1;

//convert to array of char
char[] stringArray;
stringArray = bodyText.toCharArray();

//convert to int
int i = (int)(stringArray[0]);
int j = (int)(stringArray[2]);

//add them
int result = add(i, j);
out.println("Result = " + result);

} catch (Exception ex) { out.println("Exception: " + ex); }

} finally {

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
* Handles the HTTP
* <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);

* Handles the HTTP
* <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);

* Returns a short description of the servlet.
* @return a String containing servlet description
public String getServletInfo() {
return "Short description";
}// </editor-fold>

private int add(int i, int j) {
org.me.calculator.CalculatorWS port = service.getCalculatorWSPort();
return port.add(i, j);

(3) index.jsp of client service

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<form name="Test" method="post" action="SpellCheckServlet">
<p>Enter the addition (i+j):</p>
<p><textarea rows="7" name="TextArea1" cols="40" ID="Textarea1"></textarea></p>
<input type="submit" value="perform addition" name="spellcheckbutton">

(4) the wsdl file mapped under the configuration files of the client service CalculatorWS.wsdl

<?xml version='1.0' encoding='UTF-8'?><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://calculator.me.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://calculator.me.org/" name="CalculatorWS">
<xsd:import namespace="http://calculator.me.org/" schemaLocation="http://localhost:8080/CalculatorWS/CalculatorWS?xsd=1"/>
<message name="add">
<part name="parameters" element="tns:add"/>
<message name="addResponse">
<part name="parameters" element="tns:addResponse"/>
<portType name="CalculatorWS">
<operation name="add">
<input wsam:Action="http://calculator.me.org/CalculatorWS/addRequest" message="tns:add"/>
<output wsam:Action="http://calculator.me.org/CalculatorWS/addResponse" message="tns:addResponse"/>
<binding name="CalculatorWSPortBinding" type="tns:CalculatorWS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="add">
<soap:operation soapAction=""/>
<soap:body use="literal"/>
<soap:body use="literal"/>
<service name="CalculatorWS">
<port name="CalculatorWSPort" binding="tns:CalculatorWSPortBinding">
<soap:address location="http://localhost:8080/CalculatorWS/CalculatorWS"/>