0

I have below code working fine. though on prod environment, i need to read the json via proxy server. How to achieve the same? I can see some google examples with https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/client/SimpleClientHttpRequestFactory.html for simple REST requests via proxy, but not sure i can use that in this case for json reading

            JsonFactory jasonFactory = new JsonFactory();
            URL productFeedFile = new URL("**URL");
            JsonParser jsonParser = jasonFactory.createParser(productFeedFile);
user2555212
  • 165
  • 1
  • 14

1 Answers1

1

Well I think that your JsonFactory converts the URL into an InputStream under the hood. If you do it on your own you could try:

//Proxy instance, proxy ip = 10.0.0.1 with port 8080
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.0.0.1", 8080));
URLConnection conn = new URL(urlString).openConnection(proxy);
InputStream productFeedFileAsStream = conn.getInputStream();
JsonParser jsonParser = jasonFactory.createParser(productFeedFileAsStream);
Alex Funk
  • 346
  • 2
  • 7