Requesting AJAX returning error 415

1

I'm new to web development and I'm having a little problem

I created a Webservice in Java with just one test method that adds two values received by request parameters. follow it:

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

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

    @WebMethod(operationName = "soma")
    public Integer soma(@WebParam(name = "x") Integer x, @WebParam(name = "y") Integer y) {
        System.out.println("Funcionou");
        return x + y;
    }
}

Here is the Ajax requesting:

$.ajax({
    type: "POST",
    url: "WSProtocolo?wsdl/soma",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: true,
    data: JSON.stringify({parametro1: 25, parametro2: 5}),
    success: function (data) {
        alert(data + ", Sucesso!");
    }
});

In chrome Debug it only returns the error

  

415 (Unsupported Media Type)

Would anyone know to tell me what's wrong?

    
asked by anonymous 30.05.2017 / 18:22

0 answers