xml - Curl Exception HTTP 415 : Unsupported Media Type Exception in JAX-RS and Jersey -


itemprop = "text">

When I'm running a curl command at the bottom (on Windows 7) I'm getting an error (HTTP 415: unsupported media type exception ). As far as I know the jersey should be able to detect the resources, as I indicated in the curl request the content type as "app / XML". Can anyone help me solve this exception?

I am using the following curl order:

  curl-i-x post-h "content type: app / xml" -d @ sample-input. Xml http: // localhost: 8080 / JAXRS / rest / customer   

my JAXB annotated model classes:

  public class customer {@XmlAttribute ( Required = true) safe id; @ XmlElement (required = true) string protected first name; Public int getId () {return ID; } Public Zero setId (int id) {this.id = id; } Public string getFirstname () {return firstname; } Public Zero SetFirstmen (string firstname) {this.firstname = firstname; } Public string getLastname () {return lastname; } Public Zero Settlement (string last name) {this.lastname = lastname; } Public Address getAddress () {Return Address; } Public Zero Setdude (Address Address) {this.address = address; } Public string getEmail () {return email; } Public Zero Set Email (String Email) {this.email = email; } Public string getPhone () {returns phone; } Public Zero Setphone (string phone) {this.phone = phone; } @ XmlElement (required = true) protected string lastname; @ XMLElement (required = true) protected address addresses; @ XmlElement (expected = true) protected string email; @ XMLElement (required = true) protected string phone; Public Customer () {}} @ XmlRootElement (name = "address") @ XmlAccessorType (XmlAccessType.FIELD) Public category address {@XmlElement (required = true) protected int number; @ XMLElement (required = true) protected string street; @ XMLElement (expected = true) protected string city; @ XmlElement (required = true) protected string status; Public int getNumber () {return number; } Public Zero Satnumber (int no) {this.number = number; } Public string getStreet () {return road; } Public Zero Setstreet (String Street) {this.street = street; } Public string getCity () {return city; } Public Zero Set City (String City) {this.city = city; } Public String Millstate () {Return State; } Public Zero SetState (String State) {this.state = state; } Public string getZip () {return zip; } Public Zero Setzip (string zip) {this.zip = zip; } Public string getCountry () {return country; } Public zero set country (string country) {this.country = country; } @ XmlElement (required = true) protected string zip; @ XmlElement (expected = true) protected string country; Public address () {}}   

I wrote the following resources using JAS RS <{p>

  @ POST @ ({"Application / XML", "Application / Json"}) Create public feedback Customer customer (customer customer) {long customer {try = 1; Return response. Created (URI.create ("/" + Customer ID)) Creation (); } Hold (exception e) {new WebApplicationException (e, response status.INNAL_SERVER_ERROR); }}   

The contents of sample-input.xml are:

   & Lt; Country & gt; United States & lt; / Country & gt; & Lt; / Address & gt; & Lt; Email & gt; Duke@example.com< / Email & gt; & Lt; Phone & gt; 123-456-7890 & lt; / Phone & gt; & Lt; / Customer & gt;    

The problem is resolved. After JAXB annotation my client vanished from the model class:

@XmlRootElement (name = "customer") @ XmlAccessorType (XmlAccessType.FIELD)

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -