Select to view content in your preferred language

Proxy settings

4621
6
05-30-2012 04:29 AM
dw2
by
New Contributor
To access ArcGISOnline through a proxy server as shown in the following code:

ArcGISTiledMapServiceLayer tiledLayer =
      new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.getLayers().add(tiledLayer);

will not work unless the proxy settings are set correctly. Not sure what API in Runtime is available for setting the proxy settings.

The API available in Java to set proxy settings is:

System.getProperties().put("http.proxyHost", "proxyURL");
System.getProperties().put("http.proxyPort", "proxyPort");
System.getProperties().put("http.proxyUser", "userName");
System.getProperties().put("http.proxyPassword", "password");

The Java API does not set the proxy settings for ArcGIS Runtime.
0 Kudos
6 Replies
dw2
by
New Contributor
Just re-installed the latest ArcGIS Runtime SDK for Java on a Windows 64 bit machine.  The Samples demo has a dialog for setting "Proxy Host" and "Proxy Port", but it does not have additional field for setting id/password.  The Samples demo still DOES NOT work because no web map served by ArcGISOnline can be accessed through proxy server.  The exception for each demo app is:


- - - Executing sample com.esri.client.samples.Mapping.Components.LayerList - - -
org.apache.http.impl.client.AbstractAuthenticationHandler selectScheme
WARNING: Authentication scheme ntlm not supported
com.esri.core.io.EsriServiceException: Proxy Authentication Required
at com.esri.core.internal.a.a.b.a(Unknown Source)
at com.esri.core.internal.a.a.e$1.handleResponse(Unknown Source)
at com.esri.core.internal.a.a.e$1.handleResponse(Unknown Source)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:735)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
at com.esri.core.internal.a.a.e.a(Unknown Source)
at com.esri.core.internal.a.a.e.a(Unknown Source)
at com.esri.map.Layer.getMapServerInfo(Unknown Source)
at com.esri.map.ArcGISTiledMapServiceLayer$1.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
0 Kudos
EricBader
Regular Contributor II
Hi David.
Yes, correct. These input fields are missing.
We have this as a known issue, to be fixed at a later time.
Thanks for catching this!
0 Kudos
dw2
by
New Contributor
Thanks Eric.

Would that be the Apache API that needs to be used to set the proxy server credentials?  A code snippet would be very helpful.

Thanks.
0 Kudos
MaryHarvey
Esri Contributor
Agreed. This cannot be explicitly set in the Settings dialog in the Java Sample application.

Note: It is possible to set the host and port using JVM parameters (-DhttpProxy.Host=<host name or ip> -DhttpProxy.Port=<port> -Dhttp.proxyUser=<UserName> -Dhttp.proxyPassword=<somePassword>

In code the ArcGIS Runtime SDK for Java provides this API:

ProxySetup proxySetup = new ProxySetup();
String proxyHost = "myproxy.domain.com";
int proxyPort = 8080 ;
UserCredentials proxyCredentials = new UserCredentials();
proxyCredentials.setUserAccount("userName", "password");
       
try {
     ProxySetup.setupProxy(proxyHost, proxyPort, proxyCredentials);
     }
catch (EsriSecurityException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     }
0 Kudos
dw2
by
New Contributor
Thanks Mary for the code snippet!

-david
0 Kudos
dw2
by
New Contributor
The more correct form of the JVM arguments is: "-Dhttp.proxyHost=<host name or ip> -Dhttp.proxyPort=<port> -Dhttp.proxyUser=<UserName> -Dhttp.proxyPassword=<somePassword>."
0 Kudos