This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Jersey along with JAX-WS  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to create a RESTful webservice using Jersey implementation.

Simultaneously I have the JAX-WS implementation for the webservice.

I have the java beans which have been generated using the xsd. I wish to reuse the same java beans for RESTful webservice.

The GET method works fine for me but if I try to implement a POST method, I am getting issues accepting the json string as java bean and the code breaks.

for instance:

my java bean:
package ws.test;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import ws.com.ProductType;

@XmlRootElement(name="VivekRESTClass")
@XmlAccessorType(XmlAccessType.FIELD)
public class VivekRESTClass {

public VivekRESTClass(){

}

public VivekRESTClass(String id,
List product) {
super();
this.id = id;
this.productType = product;
}
@XmlElement(required=true)
protected String id;
@XmlElement(required=true)
protected List productType;

public String getId() {
return id;
}
public void setSessionId(String id) {
this.id = id;
}
public List getProduct() {
return productType;
}
public void setProduct(List productType) {
this.productType = productType;
}

}

while my REST ful class looks like:

@Path("/VivekRESTClassImpl")
public class VivekRESTClassImpl{

private static final Logger logger = Logger.getLogger(VivekRESTClassImpl.class);
@POST
@Path("/testRESTPOST")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
public VivekRESTClassOutput addItem(VivekRESTClass vivekRESTClass){

}

Now when I invoke my method using REST client, I pass a json i.e.

{"id":"22","productType":[{"name":"Vivek","quantity":3}]}

Ideally the json passed seems to be converted to java bean and then I can use the bean to get the values but now this is not happening.

I wonder if there is some configuration that needs to be done so that Jersey can work fine with the JAX-WS.

Any help will be appreciated.

Thanks
Vivek
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this in web.xml

 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!