• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Jersey Rest Client

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jersey Rest client not returns city name.


Rest Service
########


@Path("services/result");
public class Service {

@GET
@Produces("application/json")
@Path("city")
public City getCityName() {
return "New York";

}



Rest Client
#######


public class RestClient {

public static void main(String[] args) {

ClientConfig clientConfig = new DefaultClientConfig();

clientConfig.getFeatures().put(JSONConfiguration.FEATUTRE_POJO_MAPPING, Boolean.TRUE);

Client client = Client.create(clientConfig);

WebResource webRes = client.resource("http://localhost:8080/rest/services/result/city");

ClientResponse response = webRes.accept("application/json").get(City.class);

String output = response.getEntity(City.class);

}
}

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it throwing any error ? If yes. Please post it

I think you have use @Path("/city").
 
Ranch Hand
Posts: 171
Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Vishal said, "/" should be there in the @Path string. It has to be @Path("/city"), otherwise the url you are referring would be considered as http://localhost:8080/rest/services/resultcity and in this url pattern no service has declared. Just change it and let us know.
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic