if (serviceInfo.getEnvelope() instanceof EnvelopeN) {
EnvelopeN e = (EnvelopeN) serviceInfo.getEnvelope();
Envelope envelope = new Envelope(e.getXMin(), e.getYMin(), e.getXMax(), e.getYMax());
envelope.setWkid(e.getSpatialReference()!=null && e.getSpatialReference().getWKID()!=null? e.getSpatialReference().getWKID().toString(): "4326");
GeometryService gs = GeometryService.createDefaultInstance();
try {
List<Envelope> envelopes = gs.project(Arrays.asList(new Envelope[]{envelope}), "4326");
if (!envelopes.isEmpty()) {
envelope = envelopes.get(0);
StringBuilder thumbnailURL = new StringBuilder();
thumbnailURL.append(serviceInfo.getSoapUrl());