javaweb-servicesjakarta-eeconnectexception

How to publish "Hello world" Rest web service?


package my.first.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("hello")
public class Hello {

  // This method is called if TEXT_PLAIN is requested
  @GET
  @Produces(MediaType.TEXT_PLAIN)
  public String sayHelloInPlainText() {       
    return "Hello world!";
  }
 http://stackoverflow.com/questions/2893796/create-hello-world-with-restful-web-service-and-jersey
  // This method is called if HTML is requested
  @GET
  @Produces(MediaType.TEXT_HTML)
  public String sayHelloInHtml() {
    return "<html> " + "<title>" + "Hello world!" + "</title>"
        + "<body><h1>" + "Hello world!" + "</body></h1>" + "</html> ";
  }
}

This is my code I wrote web service Restful. When I publish with Test Client Then this error is coming:

IWAB0489E Error when deploying Web service to Axis runtime
  axis-admin failed with  {http://schemas.xmlsoap.org/soap/envelope/}
  Server.userException java.net.ConnectException: Connection refused: connect

How will I fix it? This is coming with Rest only, not with SOAP.


Solution

  • You have to download the jersey [implementation of REST from sunmicrosystem] and include those jars in your application apart from this you have to modify your web.xml accordingly.
    There are multiple beginners tutorial available on net - click here