dimanche 19 février 2017

Ember POST request responding with XML jersey response in JAX-RS

I have an ember application trying to make a post request to my Restful Java Web Service (JAX-RS). However, the request doesn't seem to be hitting the endpoint. Instead, the Java web service is sending the following response to ember:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<application xmlns="http://ift.tt/1d3Sj3z">
    <doc xmlns:jersey="http://jersey.java.net/" jersey:generatedBy="Jersey: 1.10 11/02/2011 04:41 PM"/>
    <grammars/>
    <resources base="http://localhost:3002/">
        <resource path="users">
            <method id="postUser" name="POST">
                <response>
                    <representation mediaType="application/json"/>
                </response>
            </method>
        </resource>
    </resources>
</application>

The web service itself prints the following message to the console

Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class java.lang.String
Feb 19, 2017 2:48:06 PM com.sun.jersey.server.wadl.generators.WadlGeneratorJAXBGrammarGenerator attachTypes
INFO: Couldn't find JAX-B element for class javax.ws.rs.core.Response

The endpoint on JAX-RS looks like this:

@Path("/users")
public class Users {
    @POST
    @Produces("application/json")
    public Response postUser() {
        System.out.println("here");
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("{}").header("Access-Control-Allow-Origin", "*").build();
    }
}

Jersey Version: jax-rs-jersey-1.10

The adapter in ember looks like this:

   export default DS.RESTAdapter.extend({
        host: 'http://localhost:3002',
    });

Thank you in advance!

Edit: When testing the request in postman, it all works with no issues. Could be something to do with headers in ember?




Aucun commentaire:

Enregistrer un commentaire