It's all about the answers!

Ask a question

CLM 5.0.2 , trying to connect to RQM using the HTTP query and it is not returning the XML rather a html file


Samanwita Majumdar (5033740) | asked Jan 21 '15, 11:34 a.m.
The code we are using to connect RQM are -
1. Login - We get no error
    public int login(String userid, String password) {
        this.userid = userid;
        this.password = password;

        int code = 0;
        try {
            httpclient.registerTrustingSSL();
            int ret = httpclient.login(userid, password);
            if (ret == HttpURLConnection.HTTP_UNAUTHORIZED) {
                System.out.println("RQMUrlUtility: Cannot authenticate to server for user "
                        + userid);
                code = -1;
            } else if (ret == HttpURLConnection.HTTP_CLIENT_TIMEOUT) {
                System.out.println("RQMUrlUtility: Timeout authenticating to server for user "
                        + userid);
                code = -1;
            }
        } catch (Exception e) {
            System.out.println("RQMUrlUtility: Cannot authenticate to server " + e);
            code = -1;
        }
        return code;
    }
}

then http query to get a test plan

Request Parameters -

USername, password, query URL

This is the query we are using to get a Test Plan-
https://<host>:<port>/qm/service/com.ibm.rqm.integration.service.IIntegrationService/resources/<Project Area>/testplan

The code snippet to do the GET is:

    RQMUrlUtlyLogin.getHttpClient().fixMethodHeader(method);

                    /*
                     * Check for the Server Response for the GET Operation
                     */
                   
                    int responseCode = RQMUrlUtlyLogin.getHttpClient().executeMethod(
                            method);
                    if (responseCode != HttpStatus.SC_OK) {
                        System.err.println("RQMUrlUtility: Method failed: "
                                + method.getStatusLine());
                        return;
                    }
                    System.out.println("RQMUrlUtility: Server Response code: " + responseCode);

                    if (responseCode<400)
                    {
                        // Read the responseCode body.
                        byte[] responseBody = method.getResponseBody();
                        BufferedWriter out = new BufferedWriter(new FileWriter(
                                sPath));
                        out.write(new String(responseBody));
                        out.close();
                        System.out
                                .println("RQMUrlUtility: [ SUCESS ] XML string retrieved from URL : \""
                                        + sAttachURL
                                        + " \" is written to file located at -: \" "
                                        + sPath + " \"");
                    }
                   
                }

This worked fine until version 5.0.1.
Is there any suggestion as to how to make it work for 5.0.2?


Comments
Paul Slauenwhite commented Jan 22 '15, 6:30 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

Do you have the HTML file contents?  Unless you did not specify the Accept = application/xml header, HTML response content generally infers an authentication issue. 

Also, it appears you are reusing the RQM 5.0.1 URL Utility source code.  Can you try the RQM 5.0.1 URL Utility with your RQM 5.0.2 server?


Samanwita Majumdar commented Jan 22 '15, 11:27 a.m. | edited Jan 22 '15, 11:33 a.m.

Attaching the html output.
Where do I need to mention Accept=application/xml header.
I am trying the RQMURLUtility source code of version 5.0.1 on a RQM server 5.0.2 server. Are you suggesting something different?


Paul Slauenwhite commented Jan 22 '15, 11:59 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

If you are using the RQM URL Utility without any modifications, the Accept header will be included in the request automatically.

One answer



permanent link
Samanwita Majumdar (5033740) | answered Jan 22 '15, 11:34 a.m.
edited Jan 22 '15, 11:59 a.m. by Paul Slauenwhite (8.4k12)
<pre>
&lt;!DOCTYPE html&gt;

&lt;!--

  Licensed Materials - Property of IBM
  (c) Copyright IBM Corporation 2005-2013. All Rights Reserved.
 
  Note to U.S. Government Users Restricted Rights:
  Use, duplication or disclosure restricted by GSA ADP Schedule
  Contract with IBM Corp.
 
--&gt;

&lt;html &gt;

&lt;head&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=10&quot;&gt;
&lt;title&gt;&lt;/title&gt;

&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;/qm/web/_style/?include=S~&amp;etag=BBpn1CdqPU_en_US&amp;_proxyURL=%2Fqm&amp;ss=FyyQI&quot;&gt;
&lt;link rel=&quot;shortcut icon&quot; href=&quot;/qm/web/net.jazz.ajax/jazz.ico&quot;&gt;

&lt;style type=&quot;text/css&quot;&gt;
#net-jazz-ajax-NoScriptMessage {
    width: 100%;
    color: #D0D0D0;
    font-size: 2em;
    text-align: center;
    position: absolute;
    top: 1%;
    z-index: 999;
}
&lt;/style&gt;

&lt;/head&gt;

&lt;body class=&quot;claro&quot;&gt;
    &lt;noscript&gt;&lt;div id=&quot;net-jazz-ajax-NoScriptMessage&quot;&gt;Javascript is either disabled or not available in your Browser&lt;/div&gt;&lt;/noscript&gt;
    &lt;div id=&quot;net-jazz-ajax-InitialLoadMessage&quot;&gt;Loading...&lt;/div&gt;
    &lt;div id=&quot;net-jazz-ajax-WorkbenchRoot&quot;&gt;&lt;/div&gt;
  
    &lt;script type=&quot;text/javascript&quot;&gt;
        djConfig = {
            isDebug: false,
            usePlainJson: true,
            baseUrl: &quot;/qm/web/dojo/&quot;,
            locale: &quot;en-us&quot;,
            localizationComplete: true
        };
        /*null*/
        net = {jazz: {ajax: {}}};
        net.jazz.ajax._contextRoot = &quot;/qm&quot;;
        net.jazz.ajax._appPath = &quot;/qm/auth/authrequired&quot;;
        net.jazz.ajax._webuiPrefix = &quot;/web/&quot;;
    &lt;/script&gt;
  
    &lt;script type=&quot;text/javascript&quot; src=&quot;/qm/web/_js/?include=S~&amp;etag=BBpn1CdqPU_en_US&amp;_proxyURL=%2Fqm&amp;ss=FyyQI&amp;locale=en-us&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
require(&quot;dojo/main&quot;).getObject(&#39;jazz.core.loader&#39;, true)._serverStartup=&quot;FyyQI&quot;;
require(&quot;dojo/main&quot;).getObject(&#39;jazz.core.loader&#39;,true)._loaded=[&quot;S&quot;];
&lt;/script&gt;

  
    &lt;script type=&quot;text/javascript&quot;&gt;
    /* &lt;![CDATA[ */
        dojo.addOnLoad( function() {
            net.jazz.ajax.ui.PlatformUI.createAndRunWorkbench(&quot;net.jazz.web.app.authrequired&quot;);
        });
    /* ]]&gt; */
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>

Comments
Paul Slauenwhite commented Jan 22 '15, 12:02 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

This indicates you were not successfully authenticated.  If you are using the RQM URL Utility without any modifications, verify your username/password.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.