AnsweredAssumed Answered

503 Error using ArcGISDynamicMapServiceLayer

Question asked by Grontag on Nov 6, 2018

So, I am trying to show an ArcGISDynamicMapServiceLayer in my Android app (I am using 10.2.9). I am doing it this way:

 

dynamicLayer = new ArcGISDynamicMapServiceLayer(url, null, creds);

dynamicLayer.setOpacity(0.4f);

mView.addLayer(dynamicLayer);

 

This is showing nothing. The credentials have the correct user and password (I can log in via web in the page with those credentials). I get this trace:

 

my.whole.package.arcgislib E/ArcGIS: url =https://arcgispre.domain.es/arcgis/rest/services/GISC/MYSERVICE/MapServer com.esri.core.io.EsriServiceException: Service Unavailable at com.esri.core.internal.io.handler.c.a(SourceFile:690) at com.esri.core.internal.io.handler.h$1.handleResponse(SourceFile:200) at com.esri.core.internal.io.handler.h$1.handleResponse(SourceFile:197) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616) at com.esri.core.internal.io.handler.h.a(SourceFile:197) at com.esri.core.internal.io.handler.h.a(SourceFile:63) at com.esri.core.internal.tasks.ags.t.a(SourceFile:39) at com.esri.android.map.ags.ArcGISDynamicMapServiceLayer.initLayer(SourceFile:280) at com.esri.android.map.ags.ArcGISDynamicMapServiceLayer$2.run(SourceFile:261) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:137) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:856) I started debugging to see what was going on.

 

In ArcGISDynamicMapServiceLayer.class, there is a method called InitLayer. Inside, we have this line:

 

MapServiceInfo var1 = this.serviceInfo != null ? (MapServiceInfo)this.serviceInfo : (new t(this.getUrl(), this.credentials)).a();

 

This line is where the exception is thrown. I go into the a() method, whatever it does. This is the method:

 

public MapServiceInfo a() throws Exception { JsonParser var1 = h.a(this.serviceURL, (Map)null, this.getServiceCredentials()); MapServiceInfo var2 = MapServiceInfo.fromJson(var1, this.serviceURL); return var2; }

 

In the first line, it goes to this method:

 

public static final JsonParser a(String var0, Map<string, string=""> var1, n var2) throws Exception { return a(var0, (Map)var1, 1, var2); }

 

which call this:

 

private static final JsonParser a(String var0, Map<string, string=""> var1, int var2, n var3) throws Exception { Object var4 = var1; JsonParser var5 = null; String var6 = a(var0, var3); try { HttpUriRequest var7 = null; AuthenticationType var15 = var3 != null && var3.b != null ? var3.b.getAuthenticationType() : null; String var9; if (var15 == AuthenticationType.TOKEN && !var0.contains("token=")) { var9 = a(var3); if (var9 != null) { if (var1 == null) { var4 = new HashMap(); } ((Map)var4).put("token", var9); } } else if (var15 == AuthenticationType.HTTP) { a(var0, var3.b); } var7 = c.a(var6, a((Map)var4), c(var3), false); var9 = (String)f.execute(var7, new BasicResponseHandler() { public String handleResponse(HttpResponse hresponse) throws IOException, HttpResponseException { c.a(hresponse); //EXCEPTION THROWN HERE return EntityUtils.toString(hresponse.getEntity(), "UTF-8"); } }); var5 = d.c(var9); var5.nextToken(); EsriSecurityException[] var10 = new EsriSecurityException[1]; String var11 = c.a(var9, var5, var6, var10, var2, var3); if (var11 != null) { return a(var11, (Map)var4, var2 + 1, var3); } if (var10[0] != null) { throw var10[0]; } } catch (SSLException var12) { throw new EsriSecurityException(-10004, "Untrusted server certificate from " + var6, var12); } catch (HttpResponseException var13) { if (var13.getMessage().contains("Unauthorized")) { throw new EsriSecurityException(-10001, "Invalid or missing user credentials", var13); } throw var13; } catch (EsriServiceException var14) { if (var14.getCode() == 401 || var14.getMessage().trim().contains("Unauthorized")) { throw new EsriSecurityException(-10001, "Invalid or missing user credentials", var14); } if (var14.getCode() != 302 && var14.getCode() != 301) { throw var14; } String var8 = var14.getMessage(); var5 = a(var8, (Map)null, 1, var3); } return var5; } The exception is thrown in c.a(httpresponse) method, which is like this: static final void a(HttpResponse var0) { StatusLine var1 = var0.getStatusLine(); if (var1.getStatusCode() < 400 && var0.getEntity() != null) { if (var1.getStatusCode() == 302 || var1.getStatusCode() == 301) { String var2 = var1.getReasonPhrase(); if (!var2.contains("?")) { Header var3 = var0.getFirstHeader("Location"); if (var3 != null) { var2 = var3.getValue(); } } throw new EsriServiceException(var1.getStatusCode(), var2); } } else { throw new EsriServiceException(var1.getStatusCode(), var1.getReasonPhrase()); } }

 

It fails to pass the first if statement, so it goes to the else, which is throwing a 503 code. Is there something I could do here? Is a server error?

 

(For clearer reading, see here: arcgis 10.2 - 503 error showing ArcGISDynamicMapServiceLayer - Geographic Information Systems Stack Exchange )

Outcomes