Liberty Repository[8.5.5.6 이상]

JAX-RS 2.0 클라이언트 구성

Java API for XML RESTful Web Services 2.0에 대해 REST 엔드포인트에 액세스하도록 클라이언트를 구성할 수 있습니다. JAX-RS 2.0은 원격 RESTful 웹 서비스에 대한 http 요청을 작성할 수 있도록 새 표준화 클라이언트 API를 소개합니다.

이 태스크 정보

클라이언트 API를 사용하여 웹 자원에 액세스하려면 Client의 인스턴스가 필요합니다. Client의 기본 인스턴스는 ClientBuilder에서 newClient 또는 build를 호출하여 얻을 수 있습니다.

프로시저

  1. server.xml 파일에서 jaxrsClient-2.0 또는 jaxrs-2.0 기능을 사용하십시오.
    <featureManager>
        <feature>jaxrs-2.0</feature>// If you only need the JAX-RS 2.0 client feature, you can enable jaxrsClient-2.0 instead of  jaxrs-2.0 
    </featureManager>
  2. JAX-RS 2.0 클라이언트를 작성하고 서버로 요청을 전송하십시오.
    javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder();
    
    javax.ws.rs.client.Client c = cb.build();
    String res = null;
    
    try {
    	res = c.target("<Resource_URL>")
                 .path("<PATH>")
                 .request()
                 .get(String.class);
    	} catch (Exception e) {
          	res = "[Error]:" + e.toString();
          		} finally {
                c.close();        
          }   
    비동기 JAX-RS 2.0 클라이언트에 대한 자세한 정보는 비동기 처리를 참조하십시오.

다음에 수행할 작업

  • com.ibm.ws.jaxrs.client.timeout 클라이언트 특성을 사용하여 제한시간 값을 설정하십시오.
    javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder();
            cb.property("com.ibm.ws.jaxrs.client.timeout", "1000"); 
            Client c = cb.build();
    팁: 제한시간 특성의 값은 밀리초 단위이며 유형은 long 또는 int여야 합니다. 값의 유형이 올바르지 않으면 다음 메시지가 표시됩니다.
    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}  
  • 클라이언트 프록시 지원을 위해 다음 클라이언트 특성을 사용하십시오.
    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
      팁: 프록시 서버 포트 값의 유형은 int여야 합니다. 기본값은 80입니다. 값 유형이 올바르지 않으면 다음 메시지가 표시됩니다.
      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.type
      팁: 프록시 서버 유형의 값은 HTTP 또는 SOCKS여야 합니다. 기본값은 HTTP입니다. 프록시 서버의 유형이 올바르지 않으면 다음 메시지가 표시됩니다.
      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}
  • com.ibm.ws.jaxrs.client.ltpa.handler 클라이언트 특성을 사용하여 SSO 쿠키를 설정하고 값을 true로 설정하십시오.
    ClientBuilder cb = ClientBuilder.newBuilder();
            Client c = cb.build();
            c.property("com.ibm.ws.jaxrs.client.ltpa.handler", "true");
    JAX-RS 2.0에서 SSL(Secure Sockets Layer) 함수를 사용하려면 ssl-1.0 또는 appSecurity-2.0 기능을 사용해야 합니다. LTPA 토큰 함수의 경우 appSecurity-2.0 기능은 필수입니다.
    참고: ssl-1.0 기능은 appSecurity-2.0 기능의 부기능입니다. jaxrsClient-2.0 기능 및 ssl-1.0 기능을 사용하는 경우 appSecurity-2.0 기능은 자동으로 사용됩니다.
  • com.ibm.ws.jaxrs.client.ssl.config 클라이언트 특성을 사용하여 server.xml의 SSL 참조 ID를 설정하십시오.
    ClientBuilder cb = ClientBuilder.newBuilder();
            cb.property("com.ibm.ws.jaxrs.client.ssl.config", "mySSLRefId"); 
            Client c = cb.build();
    참고: server.xml의 구성은 다음과 같습니다.
    <ssl id="mySSLRefId" keyStoreRef="clientKeyStore" trustStoreRef="clientTrustStore" />

주제의 유형을 표시하는 아이콘 태스크 주제

Information Center 이용 약관 | 피드백


시간소인 아이콘 마지막 업데이트 날짜: Wednesday, 2 September 2015
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-libcore-mp&topic=twlp_jaxrs2.0_clientconfig
파일 이름: twlp_jaxrs2.0_clientconfig.html