uCosminexus Application Server, Web Service Development Guide

[Contents][Glossary][Index][Back][Next]

11.4.2 Mechanism of a client API for RESTful Web Services

A client API for RESTful Web Services wraps the HttpURLConnection/HttpsURLConnection class and the JDK executes the actual HTTP communication. Hereafter, unless clearly specified, HttpURLConnection/HttpsURLConnection is collectively called HttpURLConnection.

The following figure shows the mechanism.

[Figure]

The following processes are executed in point 1. and point 2. in the figure:

1.
  • The properties such as the connection timeout are set.
  • An HTTP header is added.
  • An entity body of the HTTP request is sent through the output stream acquired from HttpURLConnection.

2.
  • An HTTP header is acquired.
  • An entity body of the HTTP response is sent through the input stream acquired from HttpURLConnection.
Organization of this subsection
(1) Relation between a user program and a client API for RESTful Web Services
(2) Relation between JDK and client API for RESTful Web Services

(1) Relation between a user program and a client API for RESTful Web Services

A client API for RESTful Web Services mutually marshals and unmarshals a Java object and an HTTP request by using the entity body reader and entity body writer. A user program, therefore, need not directly use an input stream and output stream.

(2) Relation between JDK and client API for RESTful Web Services

The client APIs for RESTful Web Services delegate the processing of a transport layer to HttpURLConnection. The various built-in methods necessary for setting properties and HTTP headers are available; however, set the same values specified in the built-in methods to HttpURLConnection. For this reason, the JDK executes the processing that uses values specified in the actual HTTP communication and built-in methods.