Web Service HTTP 404

1

This is the first time I have made an attempt at WebService, I am working with Eclipse, and I have the following class:

@Path("/AltaCliente")
public class WebServicePushNotifications {

    @POST
    @Path("/alta")
    @Produces("text/plain")
    @Consumes("text/plain")
    public String getHello() {
        return "Hello World";
    }
}

I leave the structure of my project,

When I try to access the get through

  

link    link

I get HTTP error 404

I leave the log of the console of my JBOSS

Starting weld service for deployment push_notifications.war
12:13:10,874 INFO  [org.jboss.web] (ServerService Thread Pool -- 60) JBAS018210: Register web context: /push_notifications
12:13:11,033 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 60) Initializing Mojarra 2.1.28-jbossorg-6  for context '/push_notifications'
12:13:11,753 INFO  [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 60) HV000001: Hibernate Validator 4.3.2.Final-redhat-2
12:13:12,389 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 34) JBAS015859: Deployed "push_notifications.war" (runtime-name : "push_notifications.war")
    
asked by Bruno Sosa Fast Tag 09.02.2018 в 15:34
source

1 answer

1

What happens is that this class has two web services , what you missed was to put a path to each web service , for example I leave you your own web service only with the annotation of path I only set it as an example:

@POST
@Path("/alta")
@Produces("text/plain")
@Consumes("text/plain")
public String post(String body) {
    System.out.println("body: " + body);
    String response = "";
    try {
        URL url = new URL("http://localhost:8080/OvnipressCore-0.0.1/AltaCliente");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");

        if (conn.getResponseCode() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
        }

        BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            response += output;
            System.out.println(output);
        }

        conn.disconnect();

    } catch (MalformedURLException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    }
    return response + " - Antel body: "+ body;
}

When you consume it you do it like this:

  

link

    
answered by 09.02.2018 / 15:47
source