Implementing a client by using the unmanaged RESTful web services JAX-RS 2.0 client

WebSphere® Application Server provides a thin Java™ Platform, Standard Edition 8 (Java SE 8) RESTful web services client run time to enable application developers to quickly and easily create JAX-RS client applications. The Thin Client for JAX-RS with WebSphere Application Server is a stand-alone Java SE 8 client environment that enables running unmanaged JAX-RS RESTful web services client applications in a non-WebSphere environment to invoke JAX-RS RESTful web services that are hosted by the application server.

Before you begin

支援的配置 支援的配置: You can use the Thin Client for JAX-RS with WebSphere Application Server as a stand-alone client run time in a pure Java SE environment. The Thin Client for JAX-RS running within WebSphere Application Server or WebSphere Application Client environments is not supported. In this version of the application server, other Thin Client run times provided with the application server can also reside in the CLASSPATH and coexist with the Thin Client for JAX-RS.sptcfg

Before you set up a JAX-RS unmanaged client execution environment, obtain the Thin Client for JAX-RS Java archive (JAR) file. To obtain the Thin Client for JAX-RS, install WebSphere Application Server 9.0 版 or the Application Client for WebSphere Application Server 9.0 版. The Thin Client for JAX-RS JAR file, com.ibm.jaxrs2.0.thinclient_9.0.jar, is located in the app_server_root\runtimes directory.

Copy the Thin Client for JAX-RS com.ibm.jaxrs2.0.thinclient_9.0.jar file to other machines to create a lightweight client environment that enables communications with the product. Copies of the Thin Client for JAX-RS are subject to the same terms and conditions of the license agreement for the WebSphere product where you obtained the Thin Client for JAX-RS. Refer to the license agreements for correct usage and other limitations.

The Thin Client for JAX-RS works with IBM® Software Development Kits (SDKs) Version 8.0 and higher. The Thin Client for JAX-RS is also supported on non-IBM software development kits that are V8.0 and higher.

About this task

Set up a Thin Client for JAX-RS environment by completing the following steps.

Procedure

  1. Configure the path. Enter the following command to add the Java bin directories to your path:
    [Windows][z/OS]
    set PATH=<your_JDK_bin_directory>;%PATH%
    [AIX][HP-UX][Solaris][Linux]
    export PATH=<your_JDK_bin_directory>:$PATH
  2. Configure the class path. Add the Thin Client for JAX-RS JAR file to the classpath definition; for example:
    [Windows][z/OS]
    set CLASSPATH=.;<your_jax-rs_thin_client_install_directory>\com.ibm.jaxrs2.0.thinclient_9.0.jar;
    <your_application_jars>;%CLASSPATH%
    [AIX][HP-UX][Solaris][Linux][IBM i]
    export CLASSPATH=.:<your_JAX-RS_thin_client_install_directory>/com.ibm.jaxrs2.0.thinclient_9.0.jar:
    <your_application_jars>;$CLASSPATH
  3. Enter the following command to run your client application:
    [Windows][z/OS]
    %JAVA_HOME%/bin/java <your_client_application>
    [AIX][HP-UX][Solaris][Linux][IBM i]
    $JAVA_HOME/bin/java <your_client_application>

What to do next

  • Use com.ibm.ws.jaxrs.client.connection.timeout and com.ibm.ws.jaxrs.client.receive.timeout thin client properties 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 integral. If the type of the value is invalid, the following message is displayed:
    CWTRS0700E: 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}
  • Use the following thin client properties for thin 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.port
      Tip: The type of the proxy server port value must be integral. The default value is 80. If the value type is invalid, the following message is displayed:
      CWTRS0701E: 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.type
      Tip: 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:
      CWTRS0702E: 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}
  • Configure the JAX-RS 2.0 client to validate LTPA token authentication information.
  • Secure JAX-RS thin client by using SSL.
  • Use the com.ibm.ws.jaxrs.client.disableCNCheck thin client property to disable the common name check.
    ClientBuilder cb = ClientBuilder.newBuilder();
    cb.property("com.ibm.ws.jaxrs.client.disableCNCheck", true);

指出主題類型的圖示 作業主題



時間戳記圖示 前次更新: July 9, 2016 11:18
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_jaxrs2
檔名:twbs_jaxrs2.0_imp_thinclient_runningthinc.html