
![[8.5.5.6 or later]](../ng_v8556.gif)
This topic applies to WebSphere Application Server Liberty V8.5.5.9 and earlier. For the latest Liberty topics, see the WebSphere Application Server Liberty documentation.
Configuring JAX-RS 2.0 client
For Java API for XML RESTful Web Services 2.0, you can configure the client to access REST endpoints. JAX-RS 2.0 introduces a new and standardized Client API so that you can make HTTP requests to your remote RESTful web services.
About this task
Procedure
What to do next
Use the com.ibm.ws.jaxrs.client.timeout client property to set the timeout value.
javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder(); cb.property("com.ibm.ws.jaxrs.client.timeout", "1000"); Client c = cb.build();
Tip: The value of the timeout property is milliseconds, and the type must be long or int. If the type of the value is invalid, the following message is displayed:CWWKW0700E: The timeout value {0} that you specified in the property com.ibm.ws.jaxrs.client.timeout on the JAX-RS Client side is invalid. The value is set to default 30000.{3}
Use the com.ibm.ws.jaxrs.client.connection.timeout client property and the com.ibm.ws.jaxrs.client.receive.timeout client property to set the timeout values.
- com.ibm.ws.jaxrs.client.connection.timeout
javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder(); cb.property("com.ibm.ws.jaxrs.client.connection.timeout", "1000"); Client c = cb.build();
- com.ibm.ws.jaxrs.client.receive.timeout
javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder(); cb.property("com.ibm.ws.jaxrs.client.receive.timeout", "1000"); Client c = cb.build();
Tip: The value of the timeout property is millisecond, and the type must be long or int. If the type of the value is invalid, the following message is displayed:CWWKW0700E: The timeout value {0} that you specified in the property com.ibm.ws.jaxrs.client.receive.timeout on the JAX-RS Client side is invalid. The value is set to default 30000. {3}
- com.ibm.ws.jaxrs.client.connection.timeout
- Use the following client properties for client proxy support:
ClientBuilder cb = ClientBuilder.newBuilder(); cb.property("com.ibm.ws.jaxrs.client.proxy.host", "hostname"); cb.property("com.ibm.ws.jaxrs.client.proxy.port", "8888";); cb.property("com.ibm.ws.jaxrs.client.proxy.type", "HTTP"); Client c = cb.build();
- com.ibm.ws.jaxrs.client.proxy.host
- com.ibm.ws.jaxrs.client.proxy.portTip: The type of the proxy server port value must be int. The default value is 80. If the value type is invalid, the following message is displayed:
CWWKW0701E: The proxy server port value {0} that you specified in the property com.ibm.ws.jaxrs.client.proxy.port on the JAX-RS Client side is invalid. The value is set to default 80. {3}
- com.ibm.ws.jaxrs.client.proxy.typeTip: The value of the proxy server type must be HTTP or SOCKS. The default value is HTTP. If the type of the proxy server is invalid, the following message is displayed:
CWWKW0702E: The proxy server type value {0} that you specified in the property com.ibm.ws.jaxrs.client.proxy.type on the JAX-RS Client side is invalid. The value is set to default HTTP. {3}
- Use the com.ibm.ws.jaxrs.client.ltpa.handler client property to set the SSO
cookie and set the value to true.
If you want to use the Secure Sockets Layer (SSL) function in JAX-RS 2.0, you need to enable the ssl-1.0 or appSecurity-2.0 feature. For the LTPA token function, you must enable the appSecurity-2.0 feature.ClientBuilder cb = ClientBuilder.newBuilder(); Client c = cb.build(); c.property("com.ibm.ws.jaxrs.client.ltpa.handler", "true");
For more information about how to configure the environment to run the JAX-RS 2.0 client with SSL through IHS, see Configuring IBM HTTP server SSL support.
Note: The ssl-1.0 feature is a subfeature of the appSecurity-2.0 feature. If you enable the jaxrsClient-2.0 feature and the ssl-1.0 feature, the appSecurity-2.0 feature is enabled automatically. - Use the com.ibm.ws.jaxrs.client.ssl.config client property to set the SSL
reference id of your server.xml file.
For more information about establishing trust by extracting the certificate from the IHS key file and adding it to the Liberty JKS file, see Create a key database file and certificates needed to authenticate the Web server during an SSL handshake.ClientBuilder cb = ClientBuilder.newBuilder(); cb.property("com.ibm.ws.jaxrs.client.ssl.config", "mySSLRefId"); Client c = cb.build();
Note: The configuration in the server.xml file shows as follows:<ssl id="mySSLRefId" keyStoreRef="clientKeyStore" trustStoreRef="clientTrustStore" />
Use the com.ibm.ws.jaxrs.client.disableCNCheck client property to disable the common name check.
ClientBuilder cb = ClientBuilder.newBuilder(); cb.property("com.ibm.ws.jaxrs.client.disableCNCheck", true);