Access Rational Team Concert with OSLC: a quick start guide

Read and write information to work items in Rational Team Concert using Java


IBM® Rational Team Concert™, which is based on the Jazz platform, provides a lean, collaborative lifecycle management solution. One important feature of Rational Team Concert is its ability to integrate with external systems. Every Jazz product natively has OSLC services for reading and writing information, providing an easy point of integration between Jazz and other tools. OSLC provides services using the REST API, so standard callouts make information available for every language and platform. This article demonstrates how you can authenticate, connect, retrieve, and store information in Rational Team Concert using Java.

Connect to Rational Team Concert with an SSL certificate

By default, Rational Team Concert uses a self-signed certificate when the server is configured to use secure sockets layer (SSL). You must accept the self-signed certificate before you connect to Rational Team Concert. To do this, first create a new TrustManager object, which accepts and validates the SSL certificate by checking the expiration date, certificate signature, and so on. (See the Download section to get an Eclipse project with the full source code for the examples.)

Next, create a new Array object containing an instance of TrustManager, which implements the interface X509TrustManager. Override the methods of the interface to ensure that the validation checks are not made. See Listing 1:

Listing 1. Override the methods of the interface X509TrustManager
public static void main(String[] args) throws ClientProtocolException, IOException,
       KeyManagementException, NoSuchAlgorithmException {
      TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
         public X509Certificate[] getAcceptedIssuers() {
            return null;

         public void checkclientTrusted(X509Certificate[] certs, String authType) {
            // Leave blank to trust every client

         public void checkServerTrusted(X509Certificate[] certs, String authType) {
            // Leave blank to trust every server

         public void checkClientTrusted(X509Certificate[] arg0, String arg1)
                 throws CertificateException {
            // TODO Auto-generated method stub

      } };

Next, create an instance of SSLContext:

SSLContext mySSLContext = SSLContext.getInstance("SSL");

Then, initialize the SSLContext with the TrustManager instance we created:

mySSLContext.init(null, trustAllCerts, new;

Finally, override the default SSLSocketFactory from the HttpsURLConnection service, which the Apache HTTP client uses in its connections. This step ensures that HttpsURLConnection will use the SSL context we just created:


You have now accepted the self-signed certificate. This step was necessary to complete first to ensure that the certificate will be accepted throughout the duration of the session.

Authenticate credentials

Now you'll create all the Java objects necessary to establish the connection with the server. The connection itself is pretty much the same process you would create to make any Get process. Use the Apache library to create the connection and provide the needed parameters.

Create the following objects:

DefaultHttpClient httpclient = new DefaultHttpClient();
CookieStore cookieStore = new BasicCookieStore();
HttpContext localContext = new BasicHttpContext();

localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

Instantiate an object HttpGet with the URL of the server you want to connect, including the door if necessary, followed by /jazz /authenticated/identity:

HttpGet httpGetID = new HttpGet("https://localhost:7443/ccm/authenticated/identity");

Now you're storing the server URL, creating the session, and recording it locally in the form of cookies. Call the execute method of the HttpClient object with the objects you created earlier. You're just saving your cookies, so the connection should be closed:

httpclient.execute(httpGetID, localContext);

If you want to make sure that you created your cookies correctly, try to retrieve the saved information:

List<Cookie> cookies1 = cookieStore.getCookies();
for (Cookie cookie : cookies1) {
   System.out.println("\t" + cookie.getName() + " : " + cookie.getValue());

The next step is to authenticate with the j_security_check, using a valid username and password credentials. For this step, we use the Apache HttpClient class NameValuePair:

List<NameValuePair> authFormParams = new ArrayList<NameValuePair>();
authFormParams.add(new BasicNameValuePair("j_username", "TestJazzAdmin1"));
authFormParams.add(new BasicNameValuePair("j_password", "TestJazzAdmin1"));

Now, build an UrlEcodedFormEntity which encodes the URL and credentials and performs an HTTP Post. See Listing 2:

Listing 2. Build an UrlEncodedFormEntity
UrlEncodedFormEntity encodedentity = new UrlEncodedFormEntity(authFormParams,
HttpPost httpPostAuth = new httpPost("https://localhost:7443/ccm/authenticated/j_security_check");

httpclient.execute(httpPostAuth, localContext);

It's a good idea to check now that the cookies were created correctly to avoid any problems that you might have later in connecting. This code is only informative, but if you want to make sure that cookies are stored correctly, try to retrieve the information saved:

List<Cookie> cookies2 = cookieStore.getCookies();
for (Cookie cookie : cookies2) {
      System.out.println("\t" + cookie.getName() + " : " + cookie.getValue());

If the cookie is stored correctly, your login has been validated and you have access to Rational Team Concert.

Retrieve information from a Rational Team Concert work item using its ID

Now that you have set up the connection, you can retrieve the information about a specific work item by its ID. Make a Get request to this URL:

https://localhost:9443/ccm/oslc/workitems/ID_WI.TIPO?, property2

and substitute the numeric ID of the work item for WI_ID, the expected return type for TYPE (the possible values are JSON or XML), and — if you want to return only some properties — the property IDs for property1, property2. If you want to retrieve all the information, remove the parameter. For example, see Listing 3:

Listing 3. Retrieve information about a work item
httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(
httpget.addHeader("Accept", "application/json");
httpget.addHeader("OSLC-Core-Version", "2.0");
HttpResponse response = httpclient.execute(httpget);
Header[] ooo = response.getAllHeaders();
for (Header header : ooo) {
   System.out.println(header.getName() + " - " + header.getValue());

HttpEntity entity = response.getEntity();
if (entity != null) {

// Create a response handler
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httpget, responseHandler);


In this case, a JSON representation of the contents of work item 42 is printed to the console.

Update a work item property in Rational Team Concert

To update a property of a work item, do a Put request to the same address you used in the last example:

httpclient = new DefaultHttpClient();
HttpPut httpput = new HttpPut("https://localhost:7443/ccm/oslc/workitems/42.json");

Add this header to indicate that you are requesting a change in the work item:

httpput.setHeader("Content-Type", "application/x-oslc-cm-change-request+json");

Create a HttpEntity and inform the property that you want to change to the new value. Set the entity on the Put object:

HttpEntity myEntity = new StringEntity(
           "{\"dc:title\":{\"rdf:resource\":\"Title has changed\"}}");

Make the request normally and check the console. See Listing 4:

Listing 4. Use the new objects and send the Put command
HttpResponse responsePut = httpclient.execute(httpput);
HttpEntity entityPut = responsePut.getEntity();

BufferedReader reader;
try {
   reader = new BufferedReader(new InputStreamReader(entityPut.getContent()));
   String line = reader.readLine();
   while (line != null) {
      line = reader.readLine();
} catch (IllegalStateException e) {
} catch (IOException e) {
reader.close ();

Check the title of the work item you are working with. The title should have been changed.


The Rational Team Concert integration features, such as OSLC, help you implement systems, facilitate the exchange of information, and enhance the use of external tools. Most integration requirements can be met with OSLC services, thus avoiding complex customizations and reducing deployment time. This quick guide demonstrates how to use OSLC for reading and writing information to work items in Rational Team Concert using Java.

Downloadable resources

Related topics


Sign in or register to add and subscribe to comments.

ArticleTitle=Access Rational Team Concert with OSLC: a quick start guide