Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication4;
- import generated.Ann;
- import javax.annotation.PostConstruct;
- import javax.enterprise.context.ApplicationScoped;
- import javax.ws.rs.client.Client;
- import javax.ws.rs.client.ClientBuilder;
- import javax.ws.rs.client.WebTarget;
- import javax.ws.rs.core.MediaType;
- @ApplicationScoped
- public class getservice {
- private Client client;
- private WebTarget target;
- @PostConstruct
- protected void init() {
- client = ClientBuilder.newClient();
- //target = client.target("http://www.omdbapi.com");
- target = client.target("http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~");
- }
- public Ann fetchMovie() {
- return target.queryParam("kon")
- .request(MediaType.TEXT_HTML)
- .header("Content-type", "text/html")//application_json or text_html or xml
- .get(Ann.class);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment