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.connection.timeout client property and the
com.ibm.ws.jaxrs.client.receive.timeout client property to set the timeout value.
- 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 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, the appSecurity-2.0 feature is must.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 have JAX-RS 2.0 client to run with SSL through IHS, please 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 server.xml.
For more information about establishing trust by extracting certificate from IHS key file and add it to the Liberty JKS file, please 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 server.xml 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);