Trying to retrieve oslc/workitems/catalog using Apache HttpClient
Hello, I am trying to retrieve list of project areas using Apache httpClient library.
Here is my code:
<code>
public static void main(String[] args) throws AuthenticationException, ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); WebClientDevWrapper.wrapClient(httpclient); Credentials defaultcreds = new UsernamePasswordCredentials( "jazzy", "jazzy"); String address = "https://localhost:9443/ccm/oslc/workitems/catalog"; HttpGet httpget = new HttpGet(address); HttpRequest request = new BasicHttpRequest("GET", address); request.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); httpget.addHeader(new BasicScheme().authenticate(defaultcreds, request)); try { HttpResponse resp = httpclient.execute(httpget); InputStream is = resp.getEntity().getContent(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line = ""; while ((line = rd.readLine()) != null) { System.out.println(line); } } finally { httpget.releaseConnection(); } } </code>
Unfortunately instead of xml file I am receiving weird html file:
Here is my code:
<code>
public static void main(String[] args) throws AuthenticationException, ClientProtocolException, IOException { HttpClient httpclient = new DefaultHttpClient(); WebClientDevWrapper.wrapClient(httpclient); Credentials defaultcreds = new UsernamePasswordCredentials( "jazzy", "jazzy"); String address = "https://localhost:9443/ccm/oslc/workitems/catalog"; HttpGet httpget = new HttpGet(address); HttpRequest request = new BasicHttpRequest("GET", address); request.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); httpget.addHeader(new BasicScheme().authenticate(defaultcreds, request)); try { HttpResponse resp = httpclient.execute(httpget); InputStream is = resp.getEntity().getContent(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line = ""; while ((line = rd.readLine()) != null) { System.out.println(line); } } finally { httpget.releaseConnection(); } } </code>
Unfortunately instead of xml file I am receiving weird html file:
HTML file was removed by moderatorHow can I return list of project areas in xml form? For clarification: typing https://localhost:9443/ccm/oslc/workitems/catalog in web browser returns me proper xml file.
One answer
Hello
this topic is covered in the OSLC workshop on Jazz.net. https://jazz.net/library/article/635
this topic is covered in the OSLC workshop on Jazz.net. https://jazz.net/library/article/635