Guest User

getservice

a guest
Apr 14th, 2015
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1.  
  2. package javaapplication4;
  3.  
  4. import generated.Ann;
  5. import javax.annotation.PostConstruct;
  6. import javax.enterprise.context.ApplicationScoped;
  7. import javax.ws.rs.client.Client;
  8. import javax.ws.rs.client.ClientBuilder;
  9. import javax.ws.rs.client.WebTarget;
  10. import javax.ws.rs.core.MediaType;
  11.  
  12. @ApplicationScoped
  13. public class getservice {
  14.  
  15. private Client client;
  16. private WebTarget target;
  17.  
  18. @PostConstruct
  19. protected void init() {
  20. client = ClientBuilder.newClient();
  21. //target = client.target("http://www.omdbapi.com");
  22. target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~");
  23. }
  24.  
  25. public Ann fetchMovie() {
  26.  
  27. return target.queryParam("kon")
  28. .request(MediaType.TEXT_HTML)
  29. .header("Content-type", "text/html")//application_json or text_html or xml
  30. .get(Ann.class);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment