Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • DSS /

For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

avatar image
Question by gregory_deprecated_0 · Apr 06, 2017 at 08:43 AM · dss-rest-apidatascope-selectdssapijavaauthenticationproxy

DSS Java API - Extract via https proxy

Hi,

I downloaded the java test code from TR to retrieve data from DSS.

I'm trying to run DSS2EndOfDayClient.java but I can't pass through my proxy servers.

Can you give me the code to add the proxy server name and user/password ?

Thank you !

People who like this

0 Show 1
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
steven.peng ♦♦ · Apr 13, 2017 at 01:00 PM 0
Share

Hi, @gregory

Thank you for your participation in the forum.

Is the reply below satisfactory in resolving your query? If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question. Thanks,

AHS

7 Replies

  • Sort: 
avatar image
Best Answer
Answer by gregory_deprecated_0 · May 29, 2017 at 05:18 AM

Hi, I solved my issues, see below.

/* * ==================================================================== * This Java example demonstrate how to make an HTTPS request to DSS2 * to retrieve a Session Token. This sample is written for use with a * proxy server. *  * To run this example, you must provide a DSS2 username, password and * the proxy server hostname and proxy port. * ==================================================================== */package bnpparibas.ip.datascopehttps;
import org.apache.http.Header;import org.apache.http.HttpHost;import org.apache.http.HttpResponse;import org.apache.http.auth.AuthScope;import org.apache.http.auth.UsernamePasswordCredentials;import org.apache.http.client.ClientProtocolException;import org.apache.http.client.CredentialsProvider;import org.apache.http.client.ResponseHandler;import org.apache.http.client.methods.HttpGet;import org.apache.http.client.methods.HttpPost;import org.apache.http.conn.ssl.SSLConnectionSocketFactory;import org.apache.http.conn.ssl.SSLContextBuilder;import org.apache.http.conn.ssl.TrustSelfSignedStrategy;import org.apache.http.entity.StringEntity;import org.apache.http.impl.client.BasicCredentialsProvider;import org.apache.http.impl.client.BasicResponseHandler;import org.apache.http.impl.client.CloseableHttpClient;import org.apache.http.impl.client.HttpClients;import org.apache.http.impl.conn.DefaultProxyRoutePlanner;import org.json.JSONArray;import org.json.JSONException;import org.json.JSONObject;import org.json.JSONOrderedObject;
import java.io.*;import java.net.MalformedURLException;import java.security.KeyManagementException;import java.security.KeyStoreException;import java.security.NoSuchAlgorithmException;import java.util.ArrayList;import java.util.List;import java.util.Scanner;
public class DSS2ProxyTokenClient { private static final String urlHost = "https://hosted.datascopeapi.reuters.com/RestApi/v1"; private String sessionToken = ""; private CloseableHttpClient httpClient;
 public static void main(String[] args) throws Exception {
                
 if (args.length < 4) { System.out.println("Please enter ARGS : Reuters UserName / Reuters User Pwd / Proxy Name / Proxy Port / Proxy UserName / Proxy User Pwd"); System.exit(-1); }
 int pPort = Integer.parseInt(args[3]);
 DSS2ProxyTokenClient dss2 = new DSS2ProxyTokenClient(); dss2.getSessionToken(args[2], pPort, args[4], args[5], args[0], args[1]); promptEnterKey();
 // End Of Day On Demand Extraction report dss2.endOfDayExtractRequest();
 dss2.httpClient.close(); }
 public void getSessionToken(String proxyHostName, int proxyPortNumber, String proxyUsername, String proxyPassword, String username, String password) {
                
 try { // Set proxy information for HTTP Components HttpHost proxy = new HttpHost(proxyHostName, proxyPortNumber); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(proxyHostName, proxyPortNumber, AuthScope.ANY_REALM), new UsernamePasswordCredentials(proxyUsername, proxyPassword));
 SSLContextBuilder sslContextBuilder = new SSLContextBuilder(); sslContextBuilder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContextBuilder.build()); httpClient = HttpClients.custom() .setSSLSocketFactory(sslsf) .setRoutePlanner(routePlanner) .setDefaultCredentialsProvider(credsProvider) .build();
 // Issue a POST request HttpPost httppost = new HttpPost(urlHost + "/Authentication/RequestToken"); httppost.addHeader("content-type", "application/json; charset=UTF-8");
 JSONObject TokenRequest = new JSONObject() .put("Credentials", new JSONObject() .put("Username", username) .put("Password", password));
 StringEntity requestBody = new StringEntity(TokenRequest.toString());
 httppost.setEntity(requestBody);
 ResponseHandler<String> responseHandler = new BasicResponseHandler();
 String response = httpClient.execute(httppost, responseHandler); JSONObject jsonResponse = new JSONObject(response);
 sessionToken = jsonResponse.get("value").toString(); System.out.println("Session Token (expires in 24 hours):\n" + sessionToken);
 } catch (MalformedURLException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyStoreException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } }
Comment
Christiaan Meihsl

People who like this

1 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Christiaan Meihsl ♦♦ · May 29, 2017 at 07:02 AM 0
Share

Thank you for sharing, glad you got it to work.

avatar image
REFINITIV
Answer by Christiaan Meihsl · Apr 06, 2017 at 09:58 AM

@gregory, the way to setup proxy settings of a java application is explained in the java documentation available on the Oracle portal.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
Answer by gregory_deprecated_0 · Apr 06, 2017 at 10:28 AM

yes, I know, but I'm not a dev guy, I don't know how to use it or where to copy the new code.

I just need this for a test with DSS. In fact, the exemple from TR in not complete, proxy management is missing.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by zoya faberov · Apr 06, 2017 at 12:44 PM

Hello @Gregory,

When you run the example, please try adding on the command line:

-Dhttps.proxyHost=YOURPROXYHOST -Dhttps.proxyPort=YOURPROXYPORT

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by Gurpreet · Apr 06, 2017 at 01:03 PM

@zoya.farberov @gregory

The command line proxy properties to JVM will not be picked up by Apache HTTP Components, unless HTTPClient is specifically instructed to do so. Following code snippet will do the trick.

HttpHost proxy = new HttpHost(proxyHostName, proxyPortNumber);
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
CloseableHttpClient httpclient = HttpClients.custom()
    .setRoutePlanner(routePlanner)
    .build();

We are working on an example which will show how to use DSS with proxy server. Will let you know when it is available.

Comment
gregory_deprecated_0

People who like this

1 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by Gurpreet · Apr 26, 2017 at 08:53 AM

@gregory

Can you please try the attached example and let me know if it works for you. dss2proxytokenclient.zip


dss2proxytokenclient.zip (1.3 KiB)
Comment

People who like this

0 Show 4 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
gregory_deprecated_0 · Apr 27, 2017 at 11:17 AM 0
Share

Hi, when I build this file, I'm getting only this message:

Please enter DSS2 Username, Password, Proxy hostname, Proxy Port

Process finished with exit code -1

and I do not have any prompt asking me for some credentials.
avatar image
REFINITIV
Christiaan Meihsl ♦♦ gregory_deprecated_0 · Apr 27, 2017 at 11:38 AM 0
Share

@gregory

The program expects those 4 parameters in the run command. When you run it, add the 4 params in the command line, somewhat like this:

java -classpath "C:\Java\DSS2_Java_Examples\src;C:\Java\DSS2_Java_Examples\lib\commons-codec-1.9.jar;C:\Java\DSS2_Java_Examples\lib\commons-logging-1.2.jar;C:\Java\DSS2_Java_Examples\lib\httpclient-4.4.jar;C:\Java\DSS2_Java_Examples\lib\httpcore-4.4.jar;C:\Java\DSS2_Java_Examples\src" com.thomsonreuters.dss.api.example.DSS2ProxyTokenClient 123456 password proxyhost proxyport

Adapt this to your own classpath, and set your values for the 4 parameters ...

avatar image
gregory_deprecated_0 Christiaan Meihsl ♦♦ · Apr 28, 2017 at 03:12 AM 0
Share

That's better but our proxy needs username and password too.

Error message:

org.apache.http.client.HttpResponseException: authenticationrequired

avatar image
Answer by parameshwar.balla · May 25, 2017 at 03:50 PM

I ran through the proxy client, but i get the below error "org.apache.http.client.HttpResponseException: Method Not Allowed"

any help here

Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Gurpreet ♦♦ · May 26, 2017 at 10:44 AM 0
Share

I will contact you offline to understand the issue.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
16 People are following this question.

Related Questions

TRTH/DSS - Instrument Search API - CLK1 not found

Error: Max retries exceeded with url: /RestApi/v1/Authentication/RequestToken

How to schedule DSS Legal Entity Detail extraction with Java REST API

​How can I get API token for access to reuters API ?

DSS account for testing purpose

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges