-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestClientOne.java
More file actions
51 lines (39 loc) · 1.34 KB
/
RestClientOne.java
File metadata and controls
51 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.javaee7.chapter08;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
//import javax.ws.rs.client.ClientFactory;
/**
*
* @author Juneau
*/
@ManagedBean(name="restClientOne")
public class RestClientOne {
private String clientOutput;
// May be able to do @Inject before final release
public void testServiceOne(){
// Obtain an instance of the client
Client client = javax.ws.rs.client.ClientBuilder.newClient();
WebTarget webTarget = client.target("http://localhost:8080/IntroToJavaEE7/rest/simplerest");
Response res = webTarget.request("text/plain").get();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_INFO, "Invoked test client",
"Invoked test client"));
setClientOutput(res.toString());
}
/**
* @return the clientOutput
*/
public String getClientOutput() {
return clientOutput;
}
/**
* @param clientOutput the clientOutput to set
*/
public void setClientOutput(String clientOutput) {
this.clientOutput = clientOutput;
}
}