12.6.3 Webリソースクライアントを実行する
cjclstartapコマンドを使用して,Webリソースクライアントを実行します。
Webリソースクライアントの実行例を次に示します。
> cd c:\temp\jaxrs\works\tutorial\client\ > "%COSMINEXUS_HOME%\CC\client\bin\cjclstartap" com.sample.client. SampleClient webhost 8085
cjclstartapコマンドが正常に終了すると,Webリソースクライアントの実行結果が表示されます。Webリソースクライアントの開発方法ごとの,実行結果の表示例を次に示します。
-
クライアントAPIを利用する場合
KDJE40053-I The cjclstartap command will now start. (directory for the user definition file = c:\temp\jaxrs\works\tutorial\client, PID = 2636) Demonstration 13 started. This demonstrates how to use Client API to receive a response as a ClientResponse. This demonstrates usage of @Encoded at @CookieParam. Automatic URI decoding should be disabled. The target URL is "http://webhost:8085/tutorial/root/getCookieParam". The HTTP method is "GET". Connection and interaction ended successfully. Response headers are {Transfer-Encoding=[chunked], Date=[Tue, 27 Dec 2011 0 7:59:41 GMT], Content-Type=[text/html], Server=[CosminexusComponentContainer]}. Response entity is CookieParam: cookie%20value, which means target resource completed the process described above without any problem. Demonstration 13 ended successfully. Demonstration 14 started. This demonstrates how to send a ClientRequest and receive a ClientResponse by using Client#handle(ClientRequest request). This demonstrates usage of @Consumes and @Produces. The target URL is "http://webhost:8085/tutorial/root". The HTTP method is "POST". Connection and interaction ended successfully. Response headers are {Transfer-Encoding=[chunked], Date=[Tue, 27 Dec 2011 0 7:59:41 GMT], Content-Type=[application/xml], Server=[CosminexusComponentContainer]}. Response entity is <FormParam>formValue</FormParam>, which means target resource completed the process described above without any problem. Demonstration 14 ended successfully. Demonstration 15 started. This demonstrates JSON support of CJR. This demonstrates POJO and JSON mapping. The target URL is "http://webhost:8085/tutorial/root/PojoJsonMapping". The HTTP method is "POST". Connection and interaction ended successfully. Response is Record [Name=New Record Name, Grades=[5, 6, 7]], which means target resource completed the process described above without any problem. Demonstration 15 ended successfully. ----- Successfully Ended ----- KDJE40054-I The cjclstartap command was stopped. (PID = 2636, exit status = 0)
-
HttpURLConnectionを利用する場合
KDJE40053-I The cjclstartap command will now start. (directory for the user definition file = c:\temp\jaxrs\works\tutorial\client, PID = 2636) Demonstration 1 started. This demonstrates injection of javax.ws.rs.core.Request instance onto resource class field by using @Context. The target URL is "http://webhost:8085/tutorial/root". The HTTP method is "GET". Connection and interaction ended successfully. Response headers are {null=[HTTP/1.1 200 OK], Transfer-Encoding=[chunked], Date=[Tue, 27 Dec 2011 0 7:59:41 GMT], Content-Type=[text/html], Server=[CosminexusComponentContainer]}. Response entity is RequestMethod: GET, which means target resource completed the process described above without any problem. Demonstration 1 ended successfully. Demonstration 2 started. This demonstrates injection of QueryParam onto resource bean setter method by using @QueryParam. The target URL is "http://webhost:8085/tutorial/root/getQueryParam?queryParam=queryValue". The HTTP method is "GET". Connection and interaction ended successfully. Response headers are {null=[HTTP/1.1 200 OK], Transfer-Encoding=[chunked], Date=[Tue, 27 Dec 2011 0 7:59:41 GMT], Content-Type=[text/html], Server=[CosminexusComponentContainer]}. Response entity is QueryParameter: queryValue, which means target resource completed the process described above without any problem. Demonstration 2 ended successfully. ----- Successfully Ended ----- KDJE40054-I The cjclstartap command was stopped. (PID = 2636, exit status = 0)
イタリック体になっている個所は,実行したタイミングや環境によって変わります。
cjclstartapコマンドについては,マニュアル「アプリケーションサーバ リファレンス コマンド編」の「cjclstartap(Javaアプリケーションの開始)」を参照してください。